diff --git a/libethereum/State.h b/libethereum/State.h
index 451a34806..336c58b1a 100644
--- a/libethereum/State.h
+++ b/libethereum/State.h
@@ -138,6 +138,7 @@ public:
static OverlayDB openDB(std::string _path, WithExisting _we = WithExisting::Trust);
static OverlayDB openDB(WithExisting _we = WithExisting::Trust) { return openDB(std::string(), _we); }
OverlayDB const& db() const { return m_db; }
+ OverlayDB& db() { return m_db; }
/// @returns the set containing all addresses currently in use in Ethereum.
/// @throws InterfaceNotSupported if compiled without ETH_FATDB.
diff --git a/libjsqrc/ethereumjs/.bowerrc b/libjsqrc/ethereumjs/.bowerrc
index c3a8813e8..707e36bd6 100644
--- a/libjsqrc/ethereumjs/.bowerrc
+++ b/libjsqrc/ethereumjs/.bowerrc
@@ -1,5 +1,5 @@
{
- "directory": "example/js/",
+ "directory": "bower",
"cwd": "./",
"analytics": false
-}
\ No newline at end of file
+}
diff --git a/libjsqrc/ethereumjs/.gitignore b/libjsqrc/ethereumjs/.gitignore
index c2dd6b86d..4de097726 100644
--- a/libjsqrc/ethereumjs/.gitignore
+++ b/libjsqrc/ethereumjs/.gitignore
@@ -17,3 +17,4 @@ example/js
node_modules
bower_components
npm-debug.log
+/bower
diff --git a/libjsqrc/ethereumjs/.travis.yml b/libjsqrc/ethereumjs/.travis.yml
index 6dcfc17d1..739128ee8 100644
--- a/libjsqrc/ethereumjs/.travis.yml
+++ b/libjsqrc/ethereumjs/.travis.yml
@@ -14,4 +14,5 @@ after_script:
- npm run-script build
- npm run-script karma
- npm run-script test-coveralls
+ - cd test/node && npm install && node app.js
diff --git a/libjsqrc/ethereumjs/README.md b/libjsqrc/ethereumjs/README.md
index a153b89ba..e9eca4113 100644
--- a/libjsqrc/ethereumjs/README.md
+++ b/libjsqrc/ethereumjs/README.md
@@ -1,9 +1,11 @@
# Ethereum JavaScript API
+[![Join the chat at https://gitter.im/ethereum/ethereum.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/ethereum.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
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/JSON-RPC) spec. It's available on npm as a node module, for bower and component as an embeddable js and as a meteor.js package.
-[![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][![Coverage Status][coveralls-image]][coveralls-url]
+[![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][![Coverage Status][coveralls-image]][coveralls-url][![Stories in Ready][waffle-image]][waffle-url]
@@ -36,7 +38,7 @@ Component
## Usage
Require the library (not required for the meteor package):
- var web3 = require('web3');
+ var web3 = require('ethereum.js');
Set a provider (QtSyncProvider, HttpProvider)
@@ -110,4 +112,6 @@ eth -j
[dep-dev-url]: https://david-dm.org/ethereum/ethereum.js#info=devDependencies
[coveralls-image]: https://coveralls.io/repos/ethereum/ethereum.js/badge.svg?branch=master
[coveralls-url]: https://coveralls.io/r/ethereum/ethereum.js?branch=master
+[waffle-image]: https://badge.waffle.io/ethereum/ethereum.js.svg?label=ready&title=Ready
+[waffle-url]: http://waffle.io/ethereum/ethereum.js
diff --git a/libjsqrc/ethereumjs/bower.json b/libjsqrc/ethereumjs/bower.json
index 5fe92754b..cdb588b4f 100644
--- a/libjsqrc/ethereumjs/bower.json
+++ b/libjsqrc/ethereumjs/bower.json
@@ -1,7 +1,7 @@
{
- "name": "ethereum.js",
+ "name": "web3",
"namespace": "ethereum",
- "version": "0.1.2",
+ "version": "0.2.5",
"description": "Ethereum Compatible JavaScript API",
"main": [
"./dist/ethereum.js",
diff --git a/libjsqrc/ethereumjs/dist/ethereum.js.map b/libjsqrc/ethereumjs/dist/ethereum.js.map
deleted file mode 100644
index 44144743f..000000000
--- a/libjsqrc/ethereumjs/dist/ethereum.js.map
+++ /dev/null
@@ -1,57 +0,0 @@
-{
- "version": 3,
- "sources": [
- "node_modules/browserify/node_modules/browser-pack/_prelude.js",
- "lib/solidity/abi.js",
- "lib/solidity/formatters.js",
- "lib/solidity/types.js",
- "lib/utils/config.js",
- "lib/utils/utils.js",
- "lib/web3.js",
- "lib/web3/contract.js",
- "lib/web3/db.js",
- "lib/web3/eth.js",
- "lib/web3/event.js",
- "lib/web3/filter.js",
- "lib/web3/formatters.js",
- "lib/web3/httpprovider.js",
- "lib/web3/jsonrpc.js",
- "lib/web3/net.js",
- "lib/web3/qtsync.js",
- "lib/web3/requestmanager.js",
- "lib/web3/shh.js",
- "lib/web3/signature.js",
- "lib/web3/watches.js",
- "version.json",
- "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;;ACrPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;;AC5SA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3KA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3MA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjDA;AACA;AACA;;ACFA;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.\n*/\n/** @file abi.js\n * @authors:\n * Marek Kotewicz \n * Gav Wood \n * @date 2014\n */\n\nvar utils = require('../utils/utils');\nvar c = require('../utils/config');\nvar types = require('./types');\nvar f = require('./formatters');\n\n/**\n * throw incorrect type error\n *\n * @method throwTypeError\n * @param {String} type\n * @throws incorrect type error\n */\nvar throwTypeError = function (type) {\n throw new Error('parser does not support type: ' + type);\n};\n\n/** This method should be called if we want to check if givent type is an array type\n *\n * @method isArrayType\n * @param {String} type name\n * @returns {Boolean} true if it is, otherwise false\n */\nvar isArrayType = function (type) {\n return type.slice(-2) === '[]';\n};\n\n/**\n * This method should be called to return dynamic type length in hex\n *\n * @method dynamicTypeBytes\n * @param {String} type\n * @param {String|Array} dynamic type\n * @return {String} length of dynamic type in hex or empty string if type is not dynamic\n */\nvar dynamicTypeBytes = function (type, value) {\n // TODO: decide what to do with array of strings\n if (isArrayType(type) || type === 'bytes')\n return f.formatInputInt(value.length);\n return \"\";\n};\n\nvar inputTypes = types.inputTypes();\n\n/**\n * Formats input params to bytes\n *\n * @method formatInput\n * @param {Array} abi inputs of method\n * @param {Array} params that will be formatted to bytes\n * @returns bytes representation of input params\n */\nvar formatInput = function (inputs, params) {\n var bytes = \"\";\n var toAppendConstant = \"\";\n var toAppendArrayContent = \"\";\n\n /// first we iterate in search for dynamic\n inputs.forEach(function (input, index) {\n bytes += dynamicTypeBytes(input.type, params[index]);\n });\n\n inputs.forEach(function (input, i) {\n /*jshint maxcomplexity:5 */\n var typeMatch = false;\n for (var j = 0; j < inputTypes.length && !typeMatch; j++) {\n typeMatch = inputTypes[j].type(inputs[i].type, params[i]);\n }\n if (!typeMatch) {\n throwTypeError(inputs[i].type);\n }\n\n var formatter = inputTypes[j - 1].format;\n\n if (isArrayType(inputs[i].type))\n toAppendArrayContent += params[i].reduce(function (acc, curr) {\n return acc + formatter(curr);\n }, \"\");\n else if (inputs[i].type === 'bytes')\n toAppendArrayContent += formatter(params[i]);\n else\n toAppendConstant += formatter(params[i]);\n });\n\n bytes += toAppendConstant + toAppendArrayContent;\n\n return bytes;\n};\n\n/**\n * This method should be called to predict the length of dynamic type\n *\n * @method dynamicBytesLength\n * @param {String} type\n * @returns {Number} length of dynamic type, 0 or multiplication of ETH_PADDING (32)\n */\nvar dynamicBytesLength = function (type) {\n if (isArrayType(type) || type === 'bytes')\n return c.ETH_PADDING * 2;\n return 0;\n};\n\nvar outputTypes = types.outputTypes();\n\n/** \n * Formats output bytes back to param list\n *\n * @method formatOutput\n * @param {Array} abi outputs of method\n * @param {String} bytes represention of output\n * @returns {Array} output params\n */\nvar formatOutput = function (outs, output) {\n\n output = output.slice(2);\n var result = [];\n var padding = c.ETH_PADDING * 2;\n\n var dynamicPartLength = outs.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 outs.forEach(function (out, i) {\n /*jshint maxcomplexity:6 */\n var typeMatch = false;\n for (var j = 0; j < outputTypes.length && !typeMatch; j++) {\n typeMatch = outputTypes[j].type(outs[i].type);\n }\n\n if (!typeMatch) {\n throwTypeError(outs[i].type);\n }\n\n var formatter = outputTypes[j - 1].format;\n if (isArrayType(outs[i].type)) {\n var size = f.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 (types.prefixedType('bytes')(outs[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/**\n * Should be called to create input parser for contract with given abi\n *\n * @method inputParser\n * @param {Array} contract abi\n * @returns {Object} input parser object for given json abi\n * TODO: refactor creating the parser, do not double logic from contract\n */\nvar inputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n return formatInput(method.inputs, 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/**\n * Should be called to create output parser for contract with given abi\n *\n * @method outputParser\n * @param {Array} contract abi\n * @returns {Object} output parser for given json abi\n */\nvar outputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function (output) {\n return formatOutput(method.outputs, 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\nmodule.exports = {\n inputParser: inputParser,\n outputParser: outputParser,\n formatInput: formatInput,\n formatOutput: formatOutput\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 .\n*/\n/** @file formatters.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js'); // jshint ignore:line\n*/}\n\nvar utils = require('../utils/utils');\nvar c = require('../utils/config');\n\n/**\n * Should be called to pad string to expected length\n *\n * @method padLeft\n * @param {String} string to be padded\n * @param {Number} characters that result string should have\n * @param {String} sign, by default 0\n * @returns {String} right aligned string\n */\nvar padLeft = function (string, chars, sign) {\n return new Array(chars - string.length + 1).join(sign ? sign : \"0\") + string;\n};\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 *\n * @method formatInputInt\n * @param {String|Number|BigNumber} value that needs to be formatted\n * @returns {String} right-aligned byte representation of int\n */\nvar formatInputInt = function (value) {\n var padding = c.ETH_PADDING * 2;\n BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);\n return padLeft(utils.toTwosComplement(value).round().toString(16), padding);\n};\n\n/**\n * Formats input value to byte representation of string\n *\n * @method formatInputString\n * @param {String}\n * @returns {String} left-algined byte representation of string\n */\nvar formatInputString = function (value) {\n return utils.fromAscii(value, c.ETH_PADDING).substr(2);\n};\n\n/**\n * Formats input value to byte representation of bool\n *\n * @method formatInputBool\n * @param {Boolean}\n * @returns {String} right-aligned byte representation bool\n */\nvar formatInputBool = function (value) {\n return '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');\n};\n\n/**\n * Formats input value to byte representation of real\n * Values are multiplied by 2^m and encoded as integers\n *\n * @method formatInputReal\n * @param {String|Number|BigNumber}\n * @returns {String} byte representation of real\n */\nvar formatInputReal = function (value) {\n return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128))); \n};\n\n/**\n * Check if input value is negative\n *\n * @method signedIsNegative\n * @param {String} value is hex format\n * @returns {Boolean} true if it is negative, otherwise false\n */\nvar signedIsNegative = function (value) {\n return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';\n};\n\n/**\n * Formats right-aligned output bytes to int\n *\n * @method formatOutputInt\n * @param {String} bytes\n * @returns {BigNumber} right-aligned output bytes formatted to big number\n */\nvar formatOutputInt = function (value) {\n\n value = value || \"0\";\n\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/**\n * Formats right-aligned output bytes to uint\n *\n * @method formatOutputUInt\n * @param {String} bytes\n * @returns {BigNumeber} right-aligned output bytes formatted to uint\n */\nvar formatOutputUInt = function (value) {\n value = value || \"0\";\n return new BigNumber(value, 16);\n};\n\n/**\n * Formats right-aligned output bytes to real\n *\n * @method formatOutputReal\n * @param {String}\n * @returns {BigNumber} input bytes formatted to real\n */\nvar formatOutputReal = function (value) {\n return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/**\n * Formats right-aligned output bytes to ureal\n *\n * @method formatOutputUReal\n * @param {String}\n * @returns {BigNumber} input bytes formatted to ureal\n */\nvar formatOutputUReal = function (value) {\n return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/**\n * Should be used to format output hash\n *\n * @method formatOutputHash\n * @param {String}\n * @returns {String} right-aligned output bytes formatted to hex\n */\nvar formatOutputHash = function (value) {\n return \"0x\" + value;\n};\n\n/**\n * Should be used to format output bool\n *\n * @method formatOutputBool\n * @param {String}\n * @returns {Boolean} right-aligned input bytes formatted to bool\n */\nvar formatOutputBool = function (value) {\n return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;\n};\n\n/**\n * Should be used to format output string\n *\n * @method formatOutputString\n * @param {Sttring} left-aligned hex representation of string\n * @returns {String} ascii string\n */\nvar formatOutputString = function (value) {\n return utils.toAscii(value);\n};\n\n/**\n * Should be used to format output address\n *\n * @method formatOutputAddress\n * @param {String} right-aligned input bytes\n * @returns {String} address\n */\nvar formatOutputAddress = function (value) {\n return \"0x\" + value.slice(value.length - 40, value.length);\n};\n\nmodule.exports = {\n formatInputInt: formatInputInt,\n formatInputString: formatInputString,\n formatInputBool: formatInputBool,\n formatInputReal: formatInputReal,\n formatOutputInt: formatOutputInt,\n formatOutputUInt: formatOutputUInt,\n formatOutputReal: formatOutputReal,\n formatOutputUReal: formatOutputUReal,\n formatOutputHash: formatOutputHash,\n formatOutputBool: formatOutputBool,\n formatOutputString: formatOutputString,\n formatOutputAddress: formatOutputAddress\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 .\n*/\n/** @file types.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar f = require('./formatters');\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\n/// Setups input formatters for solidity types\n/// @returns an array of input formatters \nvar inputTypes = function () {\n \n return [\n { type: prefixedType('uint'), format: f.formatInputInt },\n { type: prefixedType('int'), format: f.formatInputInt },\n { type: prefixedType('bytes'), format: f.formatInputString }, \n { type: prefixedType('real'), format: f.formatInputReal },\n { type: prefixedType('ureal'), format: f.formatInputReal },\n { type: namedType('address'), format: f.formatInputInt },\n { type: namedType('bool'), format: f.formatInputBool }\n ];\n};\n\n/// Setups output formaters for solidity types\n/// @returns an array of output formatters\nvar outputTypes = function () {\n\n return [\n { type: prefixedType('uint'), format: f.formatOutputUInt },\n { type: prefixedType('int'), format: f.formatOutputInt },\n { type: prefixedType('bytes'), format: f.formatOutputString },\n { type: prefixedType('real'), format: f.formatOutputReal },\n { type: prefixedType('ureal'), format: f.formatOutputUReal },\n { type: namedType('address'), format: f.formatOutputAddress },\n { type: namedType('bool'), format: f.formatOutputBool }\n ];\n};\n\nmodule.exports = {\n prefixedType: prefixedType,\n namedType: namedType,\n inputTypes: inputTypes,\n outputTypes: outputTypes\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 .\n*/\n/** @file config.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\n/**\n * Utils\n * \n * @module utils\n */\n\n/**\n * Utility functions\n * \n * @class [utils] config\n * @constructor\n */\n\n/// required to define ETH_BIGNUMBER_ROUNDING_MODE\nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js'); // jshint ignore:line\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\nmodule.exports = {\n ETH_PADDING: 32,\n ETH_SIGNATURE_LENGTH: 4,\n ETH_UNITS: ETH_UNITS,\n ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },\n ETH_POLLING_TIMEOUT: 1000,\n ETH_DEFAULTBLOCK: 'latest'\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 .\n*/\n/** @file utils.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\n/**\n * Utils\n * \n * @module utils\n */\n\n/**\n * Utility functions\n * \n * @class [utils] utils\n * @constructor\n */\n\nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js'); // jshint ignore:line\n*/}\n\nvar unitMap = {\n 'wei': '1',\n 'kwei': '1000',\n 'ada': '1000',\n 'mwei': '1000000',\n 'babbage': '1000000',\n 'gwei': '1000000000',\n 'shannon': '1000000000',\n 'szabo': '1000000000000',\n 'finney': '1000000000000000',\n 'ether': '1000000000000000000',\n 'kether': '1000000000000000000000',\n 'grand': '1000000000000000000000',\n 'einstein': '1000000000000000000000',\n 'mether': '1000000000000000000000000',\n 'gether': '1000000000000000000000000000',\n 'tether': '1000000000000000000000000000000'\n};\n\n\n/** Finds first index of array element matching pattern\n *\n * @method findIndex\n * @param {Array}\n * @param {Function} pattern\n * @returns {Number} index of element\n */\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/** \n * Should be called to get sting from it's hex representation\n *\n * @method toAscii\n * @param {String} string in hex\n * @returns {String} ascii string representation of hex value\n */\nvar 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 }\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/**\n * Shold be called to get hex representation (prefixed by 0x) of ascii string \n *\n * @method fromAscii\n * @param {String} string\n * @returns {String} hex representation of input string\n */\nvar toHexNative = 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/**\n * Shold be called to get hex representation (prefixed by 0x) of ascii string \n *\n * @method fromAscii\n * @param {String} string\n * @param {Number} optional padding\n * @returns {String} hex representation of input string\n */\nvar fromAscii = function(str, pad) {\n pad = pad === undefined ? 0 : pad;\n var hex = toHexNative(str);\n while (hex.length < pad*2)\n hex += \"00\";\n return \"0x\" + hex;\n};\n\n/**\n * Should be called to get display name of contract function\n * \n * @method extractDisplayName\n * @param {String} name of function/event\n * @returns {String} display name for function/event eg. multiply(uint256) -> multiply\n */\nvar extractDisplayName = function (name) {\n var length = name.indexOf('('); \n return length !== -1 ? name.substr(0, length) : name;\n};\n\n/// @returns overloaded part of function/event name\nvar extractTypeName = function (name) {\n /// TODO: make it invulnerable\n var length = name.indexOf('(');\n return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : \"\";\n};\n\n/**\n * Filters all functions from input abi\n *\n * @method filterFunctions\n * @param {Array} abi\n * @returns {Array} abi array with filtered objects of type 'function'\n */\nvar filterFunctions = function (json) {\n return json.filter(function (current) {\n return current.type === 'function'; \n }); \n};\n\n/**\n * Filters all events from input abi\n *\n * @method filterEvents\n * @param {Array} abi\n * @returns {Array} abi array with filtered objects of type 'event'\n */\nvar filterEvents = function (json) {\n return json.filter(function (current) {\n return current.type === 'event';\n });\n};\n\n/**\n * Converts value to it's decimal representation in string\n *\n * @method toDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar toDecimal = function (value) {\n return toBigNumber(value).toNumber();\n};\n\n/**\n * Converts value to it's hex representation\n *\n * @method fromDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar fromDecimal = function (value) {\n var number = toBigNumber(value);\n var result = number.toString(16);\n\n return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;\n};\n\n/**\n * Auto converts any given value into it's hex representation.\n *\n * And even stringifys objects before.\n *\n * @method toHex\n * @param {String|Number|BigNumber|Object}\n * @return {String}\n */\nvar toHex = function (val) {\n /*jshint maxcomplexity:7 */\n\n if(isBoolean(val))\n return val;\n\n if(isBigNumber(val))\n return fromDecimal(val);\n\n if(isObject(val))\n return fromAscii(JSON.stringify(val));\n\n // if its a negative number, pass it through fromDecimal\n if (isString(val)) {\n if (val.indexOf('-0x') === 0)\n return fromDecimal(val);\n else if (!isFinite(val))\n return fromAscii(val);\n }\n\n return fromDecimal(val);\n};\n\n/**\n * Returns value of unit in Wei\n *\n * @method getValueOfUnit\n * @param {String} unit the unit to convert to, default ether\n * @returns {BigNumber} value of the unit (in Wei)\n * @throws error if the unit is not correct:w\n */\nvar getValueOfUnit = function (unit) {\n unit = unit ? unit.toLowerCase() : 'ether';\n var unitValue = unitMap[unit];\n if (unitValue === undefined) {\n throw new Error('This unit doesn\\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));\n }\n return new BigNumber(unitValue, 10);\n};\n\n/**\n * Takes a number of wei and converts it to any other ether unit.\n *\n * Possible units are:\n * - kwei/ada\n * - mwei/babbage\n * - gwei/shannon\n * - szabo\n * - finney\n * - ether\n * - kether/grand/einstein\n * - mether\n * - gether\n * - tether\n *\n * @method fromWei\n * @param {Number|String} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert to, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar fromWei = function(number, unit) {\n var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10); \n};\n\n/**\n * Takes a number of a unit and converts it to wei.\n *\n * Possible units are:\n * - kwei/ada\n * - mwei/babbage\n * - gwei/shannon\n * - szabo\n * - finney\n * - ether\n * - kether/grand/einstein\n * - mether\n * - gether\n * - tether\n *\n * @method toWei\n * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert from, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar toWei = function(number, unit) {\n var returnValue = toBigNumber(number).times(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10); \n};\n\n/**\n * Takes an input and transforms it into an bignumber\n *\n * @method toBigNumber\n * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber\n * @return {BigNumber} BigNumber\n*/\nvar toBigNumber = function(number) {\n /*jshint maxcomplexity:5 */\n number = number || 0;\n if (isBigNumber(number))\n return number;\n\n if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {\n return new BigNumber(number.replace('0x',''), 16);\n }\n \n return new BigNumber(number.toString(10), 10);\n};\n\n/**\n * Takes and input transforms it into bignumber and if it is negative value, into two's complement\n *\n * @method toTwosComplement\n * @param {Number|String|BigNumber}\n * @return {BigNumber}\n */\nvar toTwosComplement = function (number) {\n var bigNumber = toBigNumber(number);\n if (bigNumber.lessThan(0)) {\n return new BigNumber(\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\", 16).plus(bigNumber).plus(1);\n }\n return bigNumber;\n};\n\n/**\n * Checks if the given string has proper length\n *\n * @method isAddress\n * @param {String} address the given HEX adress\n * @return {Boolean}\n*/\nvar isAddress = function(address) {\n if (!isString(address)) {\n return false;\n }\n\n return ((address.indexOf('0x') === 0 && address.length === 42) ||\n (address.indexOf('0x') === -1 && address.length === 40));\n};\n\n/**\n * Returns true if object is BigNumber, otherwise false\n *\n * @method isBigNumber\n * @param {Object}\n * @return {Boolean} \n */\nvar isBigNumber = function (object) {\n return object instanceof BigNumber ||\n (object && object.constructor && object.constructor.name === 'BigNumber');\n};\n\n/**\n * Returns true if object is string, otherwise false\n * \n * @method isString\n * @param {Object}\n * @return {Boolean}\n */\nvar isString = function (object) {\n return typeof object === 'string' ||\n (object && object.constructor && object.constructor.name === 'String');\n};\n\n/**\n * Returns true if object is function, otherwise false\n *\n * @method isFunction\n * @param {Object}\n * @return {Boolean}\n */\nvar isFunction = function (object) {\n return typeof object === 'function';\n};\n\n/**\n * Returns true if object is Objet, otherwise false\n *\n * @method isObject\n * @param {Object}\n * @return {Boolean}\n */\nvar isObject = function (object) {\n return typeof object === 'object';\n};\n\n/**\n * Returns true if object is boolean, otherwise false\n *\n * @method isBoolean\n * @param {Object}\n * @return {Boolean}\n */\nvar isBoolean = function (object) {\n return typeof object === 'boolean';\n};\n\n/**\n * Returns true if object is array, otherwise false\n *\n * @method isArray\n * @param {Object}\n * @return {Boolean}\n */\nvar isArray = function (object) {\n return object instanceof Array; \n};\n\nmodule.exports = {\n findIndex: findIndex,\n toHex: toHex,\n toDecimal: toDecimal,\n fromDecimal: fromDecimal,\n toAscii: toAscii,\n fromAscii: fromAscii,\n extractDisplayName: extractDisplayName,\n extractTypeName: extractTypeName,\n filterFunctions: filterFunctions,\n filterEvents: filterEvents,\n toWei: toWei,\n fromWei: fromWei,\n toBigNumber: toBigNumber,\n toTwosComplement: toTwosComplement,\n isBigNumber: isBigNumber,\n isAddress: isAddress,\n isFunction: isFunction,\n isString: isString,\n isObject: isObject,\n isBoolean: isBoolean,\n isArray: isArray\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 .\n*/\n/** @file web3.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * Gav Wood \n * @date 2014\n */\n\nvar version = require('../version.json');\nvar net = require('./web3/net');\nvar eth = require('./web3/eth');\nvar db = require('./web3/db');\nvar shh = require('./web3/shh');\nvar watches = require('./web3/watches');\nvar filter = require('./web3/filter');\nvar utils = require('./utils/utils');\nvar formatters = require('./solidity/formatters');\nvar requestManager = require('./web3/requestmanager');\nvar c = require('./utils/config');\n\n/// @returns an array of objects describing web3 api methods\nvar web3Methods = [\n { name: 'sha3', call: 'web3_sha3', inputFormatter: utils.toHex },\n];\nvar web3Properties = [\n { name: 'version.client', getter: 'web3_clientVersion' },\n { name: 'version.network', getter: 'net_version' }\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 // allow for object methods 'myObject.method'\n var objectMethods = method.name.split('.'),\n callFunction = function () {\n /*jshint maxcomplexity:8 */\n \n var callback = null,\n args = Array.prototype.slice.call(arguments),\n call = typeof method.call === 'function' ? method.call(args) : method.call;\n\n // get the callback if one is available\n if(typeof args[args.length-1] === 'function'){\n callback = args[args.length-1];\n Array.prototype.pop.call(args);\n }\n\n // add the defaultBlock if not given\n if(method.addDefaultblock) {\n if(args.length !== method.addDefaultblock)\n Array.prototype.push.call(args, (isFinite(c.ETH_DEFAULTBLOCK) ? utils.fromDecimal(c.ETH_DEFAULTBLOCK) : c.ETH_DEFAULTBLOCK));\n else\n args[args.length-1] = isFinite(args[args.length-1]) ? utils.fromDecimal(args[args.length-1]) : args[args.length-1];\n }\n\n // show deprecated warning\n if(method.newMethod)\n console.warn('This method is deprecated please use web3.'+ method.newMethod +'() instead.');\n\n return web3.manager.send({\n method: call,\n params: args,\n outputFormatter: method.outputFormatter,\n inputFormatter: method.inputFormatter,\n addDefaultblock: method.addDefaultblock\n }, callback);\n };\n\n if(objectMethods.length > 1) {\n if(!obj[objectMethods[0]])\n obj[objectMethods[0]] = {};\n\n obj[objectMethods[0]][objectMethods[1]] = callFunction;\n \n } else {\n\n obj[objectMethods[0]] = callFunction;\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 objectProperties = property.name.split('.'),\n proto = {};\n\n proto.get = function () {\n\n // show deprecated warning\n if(property.newProperty)\n console.warn('This property is deprecated please use web3.'+ property.newProperty +' instead.');\n\n\n return web3.manager.send({\n method: property.getter,\n outputFormatter: property.outputFormatter\n });\n };\n\n if (property.setter) {\n proto.set = function (val) {\n\n // show deprecated warning\n if(property.newProperty)\n console.warn('This property is deprecated please use web3.'+ property.newProperty +' instead.');\n\n return web3.manager.send({\n method: property.setter,\n params: [val],\n inputFormatter: property.inputFormatter\n });\n };\n }\n\n proto.enumerable = !property.newProperty;\n\n if(objectProperties.length > 1) {\n if(!obj[objectProperties[0]])\n obj[objectProperties[0]] = {};\n\n Object.defineProperty(obj[objectProperties[0]], objectProperties[1], proto); \n } else\n Object.defineProperty(obj, property.name, proto);\n\n });\n};\n\n/*jshint maxparams:4 */\nvar startPolling = function (method, id, callback, uninstall) {\n web3.manager.startPolling({\n method: method, \n params: [id]\n }, id, callback, uninstall); \n};\n/*jshint maxparams:3 */\n\nvar stopPolling = function (id) {\n web3.manager.stopPolling(id);\n};\n\nvar ethWatch = {\n startPolling: startPolling.bind(null, 'eth_getFilterChanges'), \n stopPolling: stopPolling\n};\n\nvar shhWatch = {\n startPolling: startPolling.bind(null, 'shh_getFilterChanges'), \n stopPolling: stopPolling\n};\n\n/// setups web3 object, and it's in-browser executed methods\nvar web3 = {\n\n version: {\n api: version.version\n },\n\n manager: requestManager(),\n providers: {},\n\n setProvider: function (provider) {\n web3.manager.setProvider(provider);\n },\n \n /// Should be called to reset state of web3 object\n /// Resets everything except manager\n reset: function () {\n web3.manager.reset(); \n },\n\n /// @returns hex string of the input\n toHex: utils.toHex,\n\n /// @returns ascii string representation of hex value prefixed with 0x\n toAscii: utils.toAscii,\n\n /// @returns hex representation (prefixed by 0x) of ascii string\n fromAscii: utils.fromAscii,\n\n /// @returns decimal representaton of hex value prefixed by 0x\n toDecimal: utils.toDecimal,\n\n /// @returns hex representation (prefixed by 0x) of decimal value\n fromDecimal: utils.fromDecimal,\n\n /// @returns a BigNumber object\n toBigNumber: utils.toBigNumber,\n\n toWei: utils.toWei,\n fromWei: utils.fromWei,\n isAddress: utils.isAddress,\n\n // provide network information\n net: {\n // peerCount: \n },\n\n\n /// eth object prototype\n eth: {\n // DEPRECATED\n contractFromAbi: function (abi) {\n console.warn('Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead.');\n\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\n /// @param filter may be a string, object or event\n /// @param eventParams is optional, this is an object with optional event eventParams params\n /// @param options is optional, this is an object with optional event options ('max'...)\n /*jshint maxparams:4 */\n filter: function (fil, eventParams, options) {\n\n // if its event, treat it differently\n if (fil._isEvent)\n return fil(eventParams, options);\n\n return filter(fil, ethWatch, formatters.outputLogFormatter);\n },\n // DEPRECATED\n watch: function (fil, eventParams, options) {\n console.warn('eth.watch() is deprecated please use eth.filter() instead.');\n return this.filter(fil, eventParams, options);\n }\n /*jshint maxparams:3 */\n },\n\n /// db object prototype\n db: {},\n\n /// shh object prototype\n shh: {\n /// @param filter may be a string, object or event\n filter: function (fil) {\n return filter(fil, shhWatch, formatters.outputPostFormatter);\n },\n // DEPRECATED\n watch: function (fil) {\n console.warn('shh.watch() is deprecated please use shh.filter() instead.');\n return this.filter(fil);\n }\n }\n};\n\n\n// ADD defaultblock\nObject.defineProperty(web3.eth, 'defaultBlock', {\n get: function () {\n return c.ETH_DEFAULTBLOCK;\n },\n set: function (val) {\n c.ETH_DEFAULTBLOCK = val;\n return c.ETH_DEFAULTBLOCK;\n }\n});\n\n\n/// setups all api methods\nsetupMethods(web3, web3Methods);\nsetupProperties(web3, web3Properties);\nsetupMethods(web3.net, net.methods);\nsetupProperties(web3.net, net.properties);\nsetupMethods(web3.eth, eth.methods);\nsetupProperties(web3.eth, eth.properties);\nsetupMethods(web3.db, db.methods());\nsetupMethods(web3.shh, shh.methods());\nsetupMethods(ethWatch, watches.eth());\nsetupMethods(shhWatch, watches.shh());\n\nmodule.exports = web3;\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 .\n*/\n/** @file contract.js\n * @authors:\n * Marek Kotewicz \n * @date 2014\n */\n\nvar web3 = require('../web3'); \nvar abi = require('../solidity/abi');\nvar utils = require('../utils/utils');\nvar eventImpl = require('./event');\nvar signature = require('./signature');\n\nvar exportNatspecGlobals = function (vars) {\n // it's used byt natspec.js\n // TODO: figure out better way to solve this\n web3._currentContractAbi = vars.abi;\n web3._currentContractAddress = vars.address;\n web3._currentContractMethodName = vars.method;\n web3._currentContractMethodParams = vars.params;\n};\n\nvar addFunctionRelatedPropertiesToContract = function (contract) {\n \n contract.call = function (options) {\n contract._isTransaction = false;\n contract._options = options;\n return contract;\n };\n\n\n contract.sendTransaction = function (options) {\n contract._isTransaction = true;\n contract._options = options;\n return contract;\n };\n // DEPRECATED\n contract.transact = function (options) {\n\n console.warn('myContract.transact() is deprecated please use myContract.sendTransaction() instead.');\n\n return contract.sendTransaction(options);\n };\n\n contract._options = {};\n ['gas', 'gasPrice', 'value', 'from'].forEach(function(p) {\n contract[p] = function (v) {\n contract._options[p] = v;\n return contract;\n };\n });\n\n};\n\nvar addFunctionsToContract = function (contract, desc, address) {\n var inputParser = abi.inputParser(desc);\n var outputParser = abi.outputParser(desc);\n\n // create contract functions\n utils.filterFunctions(desc).forEach(function (method) {\n\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function () {\n /*jshint maxcomplexity:7 */\n var params = Array.prototype.slice.call(arguments);\n var sign = signature.functionSignatureFromAscii(method.name);\n var parsed = inputParser[displayName][typeName].apply(null, params);\n\n var options = contract._options || {};\n options.to = address;\n options.data = sign + parsed;\n \n var isTransaction = contract._isTransaction === true || (contract._isTransaction !== false && !method.constant);\n var collapse = options.collapse !== false;\n \n // reset\n contract._options = {};\n contract._isTransaction = null;\n\n if (isTransaction) {\n \n exportNatspecGlobals({\n abi: desc,\n address: address,\n method: method.name,\n params: params\n });\n\n // transactions do not have any output, cause we do not know, when they will be processed\n web3.eth.sendTransaction(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 (contract[displayName] === undefined) {\n contract[displayName] = impl;\n }\n\n contract[displayName][typeName] = impl;\n });\n};\n\nvar addEventRelatedPropertiesToContract = function (contract, desc, address) {\n contract.address = address;\n contract._onWatchEventResult = function (data) {\n var matchingEvent = event.getMatchingEvent(utils.filterEvents(desc));\n var parser = eventImpl.outputParser(matchingEvent);\n return parser(data);\n };\n \n Object.defineProperty(contract, 'topics', {\n get: function() {\n return utils.filterEvents(desc).map(function (e) {\n return signature.eventSignatureFromAscii(e.name);\n });\n }\n });\n\n};\n\nvar addEventsToContract = function (contract, desc, address) {\n // create contract events\n utils.filterEvents(desc).forEach(function (e) {\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n var sign = signature.eventSignatureFromAscii(e.name);\n var event = eventImpl.inputParser(address, sign, e);\n var o = event.apply(null, params);\n var outputFormatter = function (data) {\n var parser = eventImpl.outputParser(e);\n return parser(data);\n };\n\t\t\treturn web3.eth.filter(o, undefined, undefined, outputFormatter);\n };\n \n // this property should be used by eth.filter to check if object is an event\n impl._isEvent = true;\n\n var displayName = utils.extractDisplayName(e.name);\n var typeName = utils.extractTypeName(e.name);\n\n if (contract[displayName] === undefined) {\n contract[displayName] = impl;\n }\n\n contract[displayName][typeName] = impl;\n\n });\n};\n\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(abi); // creation of contract prototype\n *\n * var contractInstance = new MyContract('0x0123123121');\n *\n * contractInstance.myMethod('this is test string param for call'); // myMethod call (implicit, default)\n * contractInstance.call().myMethod('this is test string param for call'); // myMethod call (explicit)\n * contractInstance.sendTransaction().myMethod('this is test string param for transact'); // myMethod sendTransaction\n *\n * @param abi - abi json description of the contract, which is being created\n * @returns contract object\n */\nvar contract = function (abi) {\n\n // return prototype\n if(abi instanceof Array && arguments.length === 1) {\n return Contract.bind(null, abi);\n\n // deprecated: auto initiate contract\n } else {\n\n console.warn('Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead.');\n\n return new Contract(arguments[1], arguments[0]);\n }\n\n};\n\nfunction Contract(abi, address) {\n\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 // TODO: we may not want to modify input params, maybe use copy instead?\n abi.forEach(function (method) {\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 result = {};\n addFunctionRelatedPropertiesToContract(result);\n addFunctionsToContract(result, abi, address);\n addEventRelatedPropertiesToContract(result, abi, address);\n addEventsToContract(result, abi, address);\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 .\n*/\n/** @file db.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\n\n/// @returns an array of objects describing web3.db api methods\nvar methods = function () {\n return [\n { name: 'putString', call: 'db_putString'},\n { name: 'getString', call: 'db_getString'},\n { name: 'putHex', call: 'db_putHex'},\n { name: 'getHex', call: 'db_getHex'}\n ];\n};\n\nmodule.exports = {\n methods: methods\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 .\n*/\n/** @file eth.js\n * @authors:\n * Marek Kotewicz \n * Fabian Vogelsteller \n * @date 2015\n */\n\n/**\n * Web3\n * \n * @module web3\n */\n\n/**\n * Eth methods and properties\n *\n * An example method object can look as follows:\n *\n * {\n * name: 'getBlock',\n * call: blockCall,\n * outputFormatter: formatters.outputBlockFormatter,\n * inputFormatter: [ // can be a formatter funciton or an array of functions. Where each item in the array will be used for one parameter\n * utils.toHex, // formats paramter 1\n * function(param){ if(!param) return false; } // formats paramter 2\n * ]\n * },\n *\n * @class [web3] eth\n * @constructor\n */\n\n\nvar formatters = require('./formatters');\nvar utils = require('../utils/utils');\n\n\nvar blockCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? \"eth_getBlockByHash\" : \"eth_getBlockByNumber\";\n};\n\nvar transactionFromBlockCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';\n};\n\nvar uncleCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';\n};\n\nvar getBlockTransactionCountCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';\n};\n\nvar uncleCountCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';\n};\n\n/// @returns an array of objects describing web3.eth api methods\nvar methods = [\n { name: 'getBalance', call: 'eth_getBalance', addDefaultblock: 2,\n outputFormatter: formatters.convertToBigNumber},\n { name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3,\n inputFormatter: utils.toHex},\n\t{ name: 'getCode', call: 'eth_getCode', addDefaultblock: 2},\n { name: 'getBlock', call: blockCall,\n outputFormatter: formatters.outputBlockFormatter,\n inputFormatter: [utils.toHex, function(param){ return (!param) ? false : true; }]},\n { name: 'getUncle', call: uncleCall,\n outputFormatter: formatters.outputBlockFormatter,\n inputFormatter: [utils.toHex, utils.toHex, function(param){ return (!param) ? false : true; }]},\n { name: 'getCompilers', call: 'eth_getCompilers' },\n { name: 'getBlockTransactionCount', call: getBlockTransactionCountCall,\n outputFormatter: utils.toDecimal,\n inputFormatter: utils.toHex },\n { name: 'getBlockUncleCount', call: uncleCountCall,\n outputFormatter: utils.toDecimal,\n inputFormatter: utils.toHex },\n { name: 'getTransaction', call: 'eth_getTransactionByHash',\n outputFormatter: formatters.outputTransactionFormatter },\n { name: 'getTransactionFromBlock', call: transactionFromBlockCall,\n outputFormatter: formatters.outputTransactionFormatter,\n inputFormatter: utils.toHex },\n { name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2,\n outputFormatter: utils.toDecimal},\n { name: 'sendTransaction', call: 'eth_sendTransaction',\n inputFormatter: formatters.inputTransactionFormatter },\n { name: 'call', call: 'eth_call', addDefaultblock: 2,\n inputFormatter: formatters.inputCallFormatter },\n { name: 'compile.solidity', call: 'eth_compileSolidity' },\n { name: 'compile.lll', call: 'eth_compileLLL', inputFormatter: utils.toHex },\n { name: 'compile.serpent', call: 'eth_compileSerpent', inputFormatter: utils.toHex },\n { name: 'flush', call: 'eth_flush' },\n\n // deprecated methods\n { name: 'balanceAt', call: 'eth_balanceAt', newMethod: 'eth.getBalance' },\n { name: 'stateAt', call: 'eth_stateAt', newMethod: 'eth.getStorageAt' },\n { name: 'storageAt', call: 'eth_storageAt', newMethod: 'eth.getStorage' },\n { name: 'countAt', call: 'eth_countAt', newMethod: 'eth.getTransactionCount' },\n\t{ name: 'codeAt', call: 'eth_codeAt', newMethod: 'eth.getCode' },\n { name: 'transact', call: 'eth_transact', newMethod: 'eth.sendTransaction' },\n { name: 'block', call: blockCall, newMethod: 'eth.getBlock' },\n { name: 'transaction', call: transactionFromBlockCall, newMethod: 'eth.getTransaction' },\n { name: 'uncle', call: uncleCall, newMethod: 'eth.getUncle' },\n { name: 'compilers', call: 'eth_compilers', newMethod: 'eth.getCompilers' },\n { name: 'solidity', call: 'eth_solidity', newMethod: 'eth.compile.solidity' },\n { name: 'lll', call: 'eth_lll', newMethod: 'eth.compile.lll' },\n { name: 'serpent', call: 'eth_serpent', newMethod: 'eth.compile.serpent' },\n { name: 'transactionCount', call: getBlockTransactionCountCall, newMethod: 'eth.getBlockTransactionCount' },\n { name: 'uncleCount', call: uncleCountCall, newMethod: 'eth.getBlockUncleCount' },\n { name: 'logs', call: 'eth_logs' }\n];\n\n/// @returns an array of objects describing web3.eth api properties\nvar properties = [\n { name: 'coinbase', getter: 'eth_coinbase'},\n { name: 'mining', getter: 'eth_mining'},\n { name: 'gasPrice', getter: 'eth_gasPrice', outputFormatter: formatters.convertToBigNumber},\n { name: 'accounts', getter: 'eth_accounts' },\n { name: 'blockNumber', getter: 'eth_blockNumber', outputFormatter: utils.toDecimal},\n\n // deprecated properties\n { name: 'listening', getter: 'net_listening', setter: 'eth_setListening', newProperty: 'net.listening'},\n { name: 'peerCount', getter: 'net_peerCount', newProperty: 'net.peerCount'},\n { name: 'number', getter: 'eth_number', newProperty: 'eth.blockNumber'}\n];\n\n\nmodule.exports = {\n methods: methods,\n properties: properties\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 .\n*/\n/** @file event.js\n * @authors:\n * Marek Kotewicz \n * @date 2014\n */\n\nvar abi = require('../solidity/abi');\nvar utils = require('../utils/utils');\nvar signature = require('./signature');\n\n/// filter inputs array && returns only indexed (or not) inputs\n/// @param inputs array\n/// @param bool if result should be an array of indexed params on not\n/// @returns array of (not?) indexed params\nvar filterInputs = function (inputs, indexed) {\n return inputs.filter(function (current) {\n return current.indexed === indexed;\n });\n};\n\nvar inputWithName = function (inputs, name) {\n var index = utils.findIndex(inputs, function (input) {\n return input.name === name;\n });\n \n if (index === -1) {\n console.error('indexed param with name ' + name + ' not found');\n return undefined;\n }\n return inputs[index];\n};\n\nvar indexedParamsToTopics = function (event, indexed) {\n // sort keys?\n return Object.keys(indexed).map(function (key) {\n var inputs = [inputWithName(filterInputs(event.inputs, true), key)];\n\n var value = indexed[key];\n if (value instanceof Array) {\n return value.map(function (v) {\n return abi.formatInput(inputs, [v]);\n }); \n }\n return abi.formatInput(inputs, [value]);\n });\n};\n\nvar inputParser = function (address, sign, event) {\n \n // valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.filter'\n return function (indexed, options) {\n var o = options || {};\n o.address = address;\n o.topics = [];\n o.topics.push(sign);\n if (indexed) {\n o.topics = o.topics.concat(indexedParamsToTopics(event, indexed));\n }\n return o;\n };\n};\n\nvar getArgumentsObject = function (inputs, indexed, notIndexed) {\n var indexedCopy = indexed.slice();\n var notIndexedCopy = notIndexed.slice();\n return inputs.reduce(function (acc, current) {\n var value;\n if (current.indexed)\n value = indexedCopy.splice(0, 1)[0];\n else\n value = notIndexedCopy.splice(0, 1)[0];\n\n acc[current.name] = value;\n return acc;\n }, {}); \n};\n \nvar outputParser = function (event) {\n \n return function (output) {\n var result = {\n event: utils.extractDisplayName(event.name),\n number: output.number,\n hash: output.hash,\n args: {}\n };\n\n output.topics = output.topic; // fallback for go-ethereum\n if (!output.topics) {\n return result;\n }\n \n var indexedOutputs = filterInputs(event.inputs, true);\n var indexedData = \"0x\" + output.topics.slice(1, output.topics.length).map(function (topics) { return topics.slice(2); }).join(\"\");\n var indexedRes = abi.formatOutput(indexedOutputs, indexedData);\n\n var notIndexedOutputs = filterInputs(event.inputs, false);\n var notIndexedRes = abi.formatOutput(notIndexedOutputs, output.data);\n\n result.args = getArgumentsObject(event.inputs, indexedRes, notIndexedRes);\n\n return result;\n };\n};\n\nvar getMatchingEvent = function (events, payload) {\n for (var i = 0; i < events.length; i++) {\n var sign = signature.eventSignatureFromAscii(events[i].name); \n if (sign === payload.topics[0]) {\n return events[i];\n }\n }\n return undefined;\n};\n\n\nmodule.exports = {\n inputParser: inputParser,\n outputParser: outputParser,\n getMatchingEvent: getMatchingEvent\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 .\n*/\n/** @file filter.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * Gav Wood \n * @date 2014\n */\n\nvar utils = require('../utils/utils');\n\n/// Should be called to check if filter implementation is valid\n/// @returns true if it is, otherwise false\nvar implementationIsValid = function (i) {\n return !!i && \n typeof i.newFilter === 'function' && \n typeof i.getLogs === 'function' && \n typeof i.uninstallFilter === 'function' &&\n typeof i.startPolling === 'function' &&\n typeof i.stopPolling === 'function';\n};\n\n/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones\n/// @param should be string or object\n/// @returns options string or object\nvar getOptions = function (options) {\n /*jshint maxcomplexity:9 */\n\n if (typeof options === 'string') {\n return options;\n } \n\n options = options || {};\n\n if (options.topic) {\n console.warn('\"topic\" is deprecated, is \"topics\" instead');\n options.topics = options.topic;\n }\n\n if (options.earliest) {\n console.warn('\"earliest\" is deprecated, is \"fromBlock\" instead');\n options.fromBlock = options.earliest;\n }\n\n if (options.latest) {\n console.warn('\"latest\" is deprecated, is \"toBlock\" instead');\n options.toBlock = options.latest;\n }\n\n // make sure topics, get converted to hex\n if(options.topics instanceof Array) {\n options.topics = options.topics.map(function(topic){\n return utils.toHex(topic);\n });\n }\n\n\tvar asBlockNumber = function(n) {\n\t\tif (n == null)\n\t\t\treturn null;\n\t\tif (n == 'latest' || n == 'pending')\n\t\t\treturn n;\n\t\treturn utils.toHex(n);\n\t};\n\n // evaluate lazy properties\n return {\n\t\tfromBlock: asBlockNumber(options.fromBlock),\n\t\ttoBlock: asBlockNumber(options.toBlock),\n to: options.to,\n address: options.address,\n topics: options.topics\n };\n};\n\n/// Should be used when we want to watch something\n/// it's using inner polling mechanism and is notified about changes\n/// @param options are filter options\n/// @param implementation, an abstract polling implementation\n/// @param formatter (optional), callback function which formats output before 'real' callback \nvar filter = function(options, implementation, formatter) {\n if (!implementationIsValid(implementation)) {\n console.error('filter implemenation is invalid');\n return;\n }\n\n options = getOptions(options);\n var callbacks = [];\n var filterId = implementation.newFilter(options);\n\n // call the callbacks\n var onMessages = function (messages) {\n messages.forEach(function (message) {\n\t\t\tmessage = formatter ? formatter(message) : message;\n callbacks.forEach(function (callback) {\n\t\t\t\tcallback(message);\n });\n });\n };\n\n implementation.startPolling(filterId, onMessages, implementation.uninstallFilter);\n\n var watch = function(callback) {\n callbacks.push(callback);\n };\n\n var stopWatching = function() {\n implementation.stopPolling(filterId);\n implementation.uninstallFilter(filterId);\n callbacks = [];\n };\n\n var get = function () {\n var results = implementation.getLogs(filterId);\n\n return utils.isArray(results) ? results.map(function(message){\n return formatter ? formatter(message) : message;\n }) : results;\n };\n \n return {\n watch: watch,\n stopWatching: stopWatching,\n get: get,\n\n // DEPRECATED methods\n changed: function(){\n console.warn('watch().changed() is deprecated please use filter().watch() instead.');\n return watch.apply(this, arguments);\n },\n arrived: function(){\n console.warn('watch().arrived() is deprecated please use filter().watch() instead.');\n return watch.apply(this, arguments);\n },\n happened: function(){\n console.warn('watch().happened() is deprecated please use filter().watch() instead.');\n return watch.apply(this, arguments);\n },\n uninstall: function(){\n console.warn('watch().uninstall() is deprecated please use filter().stopWatching() instead.');\n return stopWatching.apply(this, arguments);\n },\n messages: function(){\n console.warn('watch().messages() is deprecated please use filter().get() instead.');\n return get.apply(this, arguments);\n },\n logs: function(){\n console.warn('watch().logs() is deprecated please use filter().get() instead.');\n return get.apply(this, arguments);\n }\n };\n};\n\nmodule.exports = filter;\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 .\n*/\n/** @file formatters.js\n * @authors:\n * Marek Kotewicz \n * Fabian Vogelsteller \n * @date 2015\n */\n\nvar utils = require('../utils/utils');\n\n/**\n * Should the input to a big number\n *\n * @method convertToBigNumber\n * @param {String|Number|BigNumber}\n * @returns {BigNumber} object\n */\nvar convertToBigNumber = function (value) {\n return utils.toBigNumber(value);\n};\n\n/**\n * Formats the input of a transaction and converts all values to HEX\n *\n * @method inputTransactionFormatter\n * @param {Object} transaction options\n * @returns object\n*/\nvar inputTransactionFormatter = function (options){\n\n // make code -> data\n if (options.code) {\n options.data = options.code;\n delete options.code;\n }\n\n ['gasPrice', 'gas', 'value'].forEach(function(key){\n options[key] = utils.fromDecimal(options[key]);\n });\n\n return options;\n};\n\n/**\n * Formats the output of a transaction to its proper values\n * \n * @method outputTransactionFormatter\n * @param {Object} transaction\n * @returns {Object} transaction\n*/\nvar outputTransactionFormatter = function (tx){\n tx.gas = utils.toDecimal(tx.gas);\n tx.gasPrice = utils.toBigNumber(tx.gasPrice);\n tx.value = utils.toBigNumber(tx.value);\n return tx;\n};\n\n/**\n * Formats the input of a call and converts all values to HEX\n *\n * @method inputCallFormatter\n * @param {Object} transaction options\n * @returns object\n*/\nvar inputCallFormatter = function (options){\n\n // make code -> data\n if (options.code) {\n options.data = options.code;\n delete options.code;\n }\n\n return options;\n};\n\n\n/**\n * Formats the output of a block to its proper values\n *\n * @method outputBlockFormatter\n * @param {Object} block object \n * @returns {Object} block object\n*/\nvar outputBlockFormatter = function(block){\n\n // transform to number\n block.gasLimit = utils.toDecimal(block.gasLimit);\n block.gasUsed = utils.toDecimal(block.gasUsed);\n block.size = utils.toDecimal(block.size);\n block.timestamp = utils.toDecimal(block.timestamp);\n block.number = utils.toDecimal(block.number);\n\n block.minGasPrice = utils.toBigNumber(block.minGasPrice);\n block.difficulty = utils.toBigNumber(block.difficulty);\n block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);\n\n if(block.transactions instanceof Array) {\n block.transactions.forEach(function(item){\n if(!utils.isString(item))\n return outputTransactionFormatter(item);\n });\n }\n\n return block;\n};\n\n/**\n * Formats the output of a log\n * \n * @method outputLogFormatter\n * @param {Object} log object\n * @returns {Object} log\n*/\nvar outputLogFormatter = function(log){\n log.blockNumber = utils.toDecimal(log.blockNumber);\n log.transactionIndex = utils.toDecimal(log.transactionIndex);\n log.logIndex = utils.toDecimal(log.logIndex);\n\n return log;\n};\n\n\n/**\n * Formats the input of a whisper post and converts all values to HEX\n *\n * @method inputPostFormatter\n * @param {Object} transaction object\n * @returns {Object}\n*/\nvar inputPostFormatter = function(post){\n\n post.payload = utils.toHex(post.payload);\n post.ttl = utils.fromDecimal(post.ttl);\n post.priority = utils.fromDecimal(post.priority);\n\n if(!(post.topics instanceof Array))\n post.topics = [post.topics];\n\n\n // format the following options\n post.topics = post.topics.map(function(topic){\n return utils.fromAscii(topic);\n });\n\n return post;\n};\n\n/**\n * Formats the output of a received post message\n *\n * @method outputPostFormatter\n * @param {Object}\n * @returns {Object}\n */\nvar outputPostFormatter = function(post){\n\n post.expiry = utils.toDecimal(post.expiry);\n post.sent = utils.toDecimal(post.sent);\n post.ttl = utils.toDecimal(post.ttl);\n post.workProved = utils.toDecimal(post.workProved);\n post.payloadRaw = post.payload;\n post.payload = utils.toAscii(post.payload);\n\n if(post.payload.indexOf('{') === 0 || post.payload.indexOf('[') === 0) {\n try {\n post.payload = JSON.parse(post.payload);\n } catch (e) { }\n }\n\n // format the following options\n post.topics = post.topics.map(function(topic){\n return utils.toAscii(topic);\n });\n\n return post;\n};\n\nmodule.exports = {\n convertToBigNumber: convertToBigNumber,\n inputTransactionFormatter: inputTransactionFormatter,\n outputTransactionFormatter: outputTransactionFormatter,\n inputCallFormatter: inputCallFormatter,\n outputBlockFormatter: outputBlockFormatter,\n outputLogFormatter: outputLogFormatter,\n inputPostFormatter: inputPostFormatter,\n outputPostFormatter: outputPostFormatter\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 .\n*/\n/** @file httpprovider.js\n * @authors:\n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * @date 2014\n */\n\nif (\"build\" !== 'build') {/*\n var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line\n*/}\n\nvar HttpProvider = function (host) {\n this.name = 'HTTP';\n this.handlers = [];\n this.host = host || 'http://localhost:8080';\n};\n\nHttpProvider.prototype.send = function (payload, callback) {\n var request = new XMLHttpRequest();\n\n // ASYNC\n if(typeof callback === 'function') {\n request.onreadystatechange = function() {\n if(request.readyState === 4) {\n var result = '';\n try {\n result = JSON.parse(request.responseText);\n } catch(error) {\n result = error;\n }\n callback(result, request.status);\n }\n };\n\n request.open('POST', this.host, true);\n request.send(JSON.stringify(payload));\n\n // SYNC\n } else {\n request.open('POST', this.host, false);\n request.send(JSON.stringify(payload));\n\n // check request.status\n if(request.status !== 200)\n return;\n return JSON.parse(request.responseText);\n \n }\n};\n\nmodule.exports = HttpProvider;\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 .\n*/\n/** @file jsonrpc.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar messageId = 1;\n\n/// Should be called to valid json create payload object\n/// @param method of jsonrpc call, required\n/// @param params, an array of method params, optional\n/// @returns valid jsonrpc payload object\nvar toPayload = function (method, params) {\n if (!method)\n console.error('jsonrpc method should be specified!');\n\n return {\n jsonrpc: '2.0',\n method: method,\n params: params || [],\n id: messageId++\n }; \n};\n\n/// Should be called to check if jsonrpc response is valid\n/// @returns true if response is valid, otherwise false \nvar isValidResponse = function (response) {\n return !!response &&\n !response.error &&\n response.jsonrpc === '2.0' &&\n typeof response.id === 'number' &&\n response.result !== undefined; // only undefined is not valid json object\n};\n\n/// Should be called to create batch payload object\n/// @param messages, an array of objects with method (required) and params (optional) fields\nvar toBatchPayload = function (messages) {\n return messages.map(function (message) {\n return toPayload(message.method, message.params);\n }); \n};\n\nmodule.exports = {\n toPayload: toPayload,\n isValidResponse: isValidResponse,\n toBatchPayload: toBatchPayload\n};\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 .\n*/\n/** @file eth.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar utils = require('../utils/utils');\n\n/// @returns an array of objects describing web3.eth api methods\nvar methods = [\n // { name: 'getBalance', call: 'eth_balanceAt', outputFormatter: formatters.convertToBigNumber},\n];\n\n/// @returns an array of objects describing web3.eth api properties\nvar properties = [\n { name: 'listening', getter: 'net_listening'},\n { name: 'peerCount', getter: 'net_peerCount', outputFormatter: utils.toDecimal },\n];\n\n\nmodule.exports = {\n methods: methods,\n properties: properties\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 .\n*/\n/** @file qtsync.js\n * @authors:\n * Marek Kotewicz \n * Marian Oancea \n * @date 2014\n */\n\nvar QtSyncProvider = function () {\n};\n\nQtSyncProvider.prototype.send = function (payload) {\n var result = navigator.qt.callMethod(JSON.stringify(payload));\n return JSON.parse(result);\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 .\n*/\n/** @file requestmanager.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * Gav Wood \n * @date 2014\n */\n\nvar jsonrpc = require('./jsonrpc');\nvar c = require('../utils/config');\n\n/**\n * It's responsible for passing messages to providers\n * It's also responsible for polling the ethereum node for incoming messages\n * Default poll timeout is 1 second\n */\nvar requestManager = function() {\n var polls = [];\n var timeout = null;\n var provider;\n\n var send = function (data, callback) {\n /*jshint maxcomplexity: 8 */\n\n // FORMAT BASED ON ONE FORMATTER function\n if(typeof data.inputFormatter === 'function') {\n data.params = Array.prototype.map.call(data.params, function(item, index){\n // format everything besides the defaultblock, which is already formated\n return (!data.addDefaultblock || index+1 < data.addDefaultblock) ? data.inputFormatter(item) : item;\n });\n\n // FORMAT BASED ON the input FORMATTER ARRAY\n } else if(data.inputFormatter instanceof Array) {\n data.params = Array.prototype.map.call(data.inputFormatter, function(formatter, index){\n // format everything besides the defaultblock, which is already formated\n return (!data.addDefaultblock || index+1 < data.addDefaultblock) ? formatter(data.params[index]) : data.params[index];\n });\n }\n\n\n var payload = jsonrpc.toPayload(data.method, data.params);\n \n if (!provider) {\n console.error('provider is not set');\n return null;\n }\n\n // HTTP ASYNC (only when callback is given, and it a HttpProvidor)\n if(typeof callback === 'function' && provider.name === 'HTTP'){\n provider.send(payload, function(result, status){\n\n if (!jsonrpc.isValidResponse(result)) {\n if(typeof result === 'object' && result.error && result.error.message) {\n console.error(result.error.message);\n callback(result.error);\n } else {\n callback(new Error({\n status: status,\n error: result,\n message: 'Bad Request'\n }));\n }\n return null;\n }\n\n // format the output\n callback(null, (typeof data.outputFormatter === 'function') ? data.outputFormatter(result.result) : result.result);\n });\n\n // SYNC\n } else {\n var result = provider.send(payload);\n\n if (!jsonrpc.isValidResponse(result)) {\n if(typeof result === 'object' && result.error && result.error.message)\n console.error(result.error.message);\n return null;\n }\n\n // format the output\n return (typeof data.outputFormatter === 'function') ? data.outputFormatter(result.result) : result.result;\n }\n \n };\n\n var setProvider = function (p) {\n provider = p;\n };\n\n /*jshint maxparams:4 */\n var startPolling = function (data, pollId, callback, uninstall) {\n polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});\n };\n /*jshint maxparams:3 */\n\n var stopPolling = function (pollId) {\n for (var i = polls.length; i--;) {\n var poll = polls[i];\n if (poll.id === pollId) {\n polls.splice(i, 1);\n }\n }\n };\n\n var reset = function () {\n polls.forEach(function (poll) {\n poll.uninstall(poll.id); \n });\n polls = [];\n\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n poll();\n };\n\n var poll = function () {\n polls.forEach(function (data) {\n // send async\n send(data.data, function(error, result){\n if (!(result instanceof Array) || result.length === 0) {\n return;\n }\n data.callback(result);\n });\n });\n timeout = setTimeout(poll, c.ETH_POLLING_TIMEOUT);\n };\n \n poll();\n\n return {\n send: send,\n setProvider: setProvider,\n startPolling: startPolling,\n stopPolling: stopPolling,\n reset: reset\n };\n};\n\nmodule.exports = requestManager;\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 .\n*/\n/** @file shh.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar formatters = require('./formatters');\n\n/// @returns an array of objects describing web3.shh api methods\nvar methods = function () {\n return [\n { name: 'post', call: 'shh_post', inputFormatter: formatters.inputPostFormatter },\n { name: 'newIdentity', call: 'shh_newIdentity' },\n { name: 'hasIdentity', call: 'shh_hasIdentity' },\n { name: 'newGroup', call: 'shh_newGroup' },\n { name: 'addToGroup', call: 'shh_addToGroup' },\n\n // deprecated\n { name: 'haveIdentity', call: 'shh_haveIdentity', newMethod: 'shh.hasIdentity' },\n ];\n};\n\nmodule.exports = {\n methods: methods\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 .\n*/\n/** @file signature.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar web3 = require('../web3'); \nvar c = require('../utils/config');\n\n/// @param function name for which we want to get signature\n/// @returns signature of function with given name\nvar functionSignatureFromAscii = function (name) {\n return web3.sha3(web3.fromAscii(name)).slice(0, 2 + c.ETH_SIGNATURE_LENGTH * 2);\n};\n\n/// @param event name for which we want to get signature\n/// @returns signature of event with given name\nvar eventSignatureFromAscii = function (name) {\n return web3.sha3(web3.fromAscii(name));\n};\n\nmodule.exports = {\n functionSignatureFromAscii: functionSignatureFromAscii,\n eventSignatureFromAscii: eventSignatureFromAscii\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 .\n*/\n/** @file watches.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\n/// @returns an array of objects describing web3.eth.filter api methods\nvar eth = function () {\n var newFilter = function (args) {\n return typeof args[0] === 'string' ? 'eth_newBlockFilter' : 'eth_newFilter';\n };\n\n return [\n { name: 'newFilter', call: newFilter },\n { name: 'uninstallFilter', call: 'eth_uninstallFilter' },\n { name: 'getLogs', call: 'eth_getFilterLogs' }\n ];\n};\n\n/// @returns an array of objects describing web3.shh.watch api methods\nvar shh = function () {\n return [\n { name: 'newFilter', call: 'shh_newFilter' },\n { name: 'uninstallFilter', call: 'shh_uninstallFilter' },\n { name: 'getLogs', call: 'shh_getMessages' }\n ];\n};\n\nmodule.exports = {\n eth: eth,\n shh: shh\n};\n\n",
- "module.exports={\n \"version\": \"0.1.3\"\n}",
- "var web3 = require('./lib/web3');\nweb3.providers.HttpProvider = require('./lib/web3/httpprovider');\nweb3.providers.QtSyncProvider = require('./lib/web3/qtsync');\nweb3.eth.contract = require('./lib/web3/contract');\nweb3.abi = require('./lib/solidity/abi');\n\nmodule.exports = web3;\n"
- ]
-}
\ No newline at end of file
diff --git a/libjsqrc/ethereumjs/dist/ethereum.min.js b/libjsqrc/ethereumjs/dist/ethereum.min.js
deleted file mode 100644
index 4aab986d6..000000000
--- a/libjsqrc/ethereumjs/dist/ethereum.min.js
+++ /dev/null
@@ -1 +0,0 @@
-require=function t(e,n,r){function o(a,u){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return o(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;ay;y++)g.push(d(e.slice(0,s))),e=e.slice(s);n.push(g)}else o.prefixedType("bytes")(t[c].type)?(l=l.slice(s),n.push(d(e.slice(0,s))),e=e.slice(s)):(n.push(d(e.slice(0,s))),e=e.slice(s))}),n},d=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),o=n.extractTypeName(t.name),i=function(){var e=Array.prototype.slice.call(arguments);return l(t.inputs,e)};void 0===e[r]&&(e[r]=i),e[r][o]=i}),e},h=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),o=n.extractTypeName(t.name),i=function(e){return m(t.outputs,e)};void 0===e[r]&&(e[r]=i),e[r][o]=i}),e};e.exports={inputParser:d,outputParser:h,formatInput:l,formatOutput:m}},{"../utils/config":4,"../utils/utils":5,"./formatters":2,"./types":3}],2:[function(t,e){var n=t("../utils/utils"),r=t("../utils/config"),o=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},i=function(t){var e=2*r.ETH_PADDING;return BigNumber.config(r.ETH_BIGNUMBER_ROUNDING_MODE),o(n.toTwosComplement(t).round().toString(16),e)},a=function(t){return n.fromAscii(t,r.ETH_PADDING).substr(2)},u=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},s=function(t){return i(new BigNumber(t).times(new BigNumber(2).pow(128)))},c=function(t){return"1"===new BigNumber(t.substr(0,1),16).toString(2).substr(0,1)},l=function(t){return t=t||"0",c(t)?new BigNumber(t,16).minus(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new BigNumber(t,16)},f=function(t){return t=t||"0",new BigNumber(t,16)},p=function(t){return l(t).dividedBy(new BigNumber(2).pow(128))},m=function(t){return f(t).dividedBy(new BigNumber(2).pow(128))},d=function(t){return"0x"+t},h=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},g=function(t){return n.toAscii(t)},y=function(t){return"0x"+t.slice(t.length-40,t.length)};e.exports={formatInputInt:i,formatInputString:a,formatInputBool:u,formatInputReal:s,formatOutputInt:l,formatOutputUInt:f,formatOutputReal:p,formatOutputUReal:m,formatOutputHash:d,formatOutputBool:h,formatOutputString:g,formatOutputAddress:y}},{"../utils/config":4,"../utils/utils":5}],3:[function(t,e){var n=t("./formatters"),r=function(t){return function(e){return 0===e.indexOf(t)}},o=function(t){return function(e){return t===e}},i=function(){return[{type:r("uint"),format:n.formatInputInt},{type:r("int"),format:n.formatInputInt},{type:r("bytes"),format:n.formatInputString},{type:r("real"),format:n.formatInputReal},{type:r("ureal"),format:n.formatInputReal},{type:o("address"),format:n.formatInputInt},{type:o("bool"),format:n.formatInputBool}]},a=function(){return[{type:r("uint"),format:n.formatOutputUInt},{type:r("int"),format:n.formatOutputInt},{type:r("bytes"),format:n.formatOutputString},{type:r("real"),format:n.formatOutputReal},{type:r("ureal"),format:n.formatOutputUReal},{type:o("address"),format:n.formatOutputAddress},{type:o("bool"),format:n.formatOutputBool}]};e.exports={prefixedType:r,namedType:o,inputTypes:i,outputTypes:a}},{"./formatters":2}],4:[function(t,e){var n=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];e.exports={ETH_PADDING:32,ETH_SIGNATURE_LENGTH:4,ETH_UNITS:n,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:BigNumber.ROUND_DOWN},ETH_POLLING_TIMEOUT:1e3,ETH_DEFAULTBLOCK:"latest"}},{}],5:[function(t,e){var n={wei:"1",kwei:"1000",ada:"1000",mwei:"1000000",babbage:"1000000",gwei:"1000000000",shannon:"1000000000",szabo:"1000000000000",finney:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",einstein:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"},r=function(t,e){for(var n=!1,r=0;rn;n+=2){var o=parseInt(t.substr(n,2),16);if(0===o)break;e+=String.fromCharCode(o)}return e},i=function(t){for(var e="",n=0;n1?(t[n[0]]||(t[n[0]]={}),t[n[0]][n[1]]=r):t[n[0]]=r})},g=function(t,e){e.forEach(function(e){var n=e.name.split("."),r={};r.get=function(){return e.newProperty&&console.warn("This property is deprecated please use web3."+e.newProperty+" instead."),_.manager.send({method:e.getter,outputFormatter:e.outputFormatter})},e.setter&&(r.set=function(t){return e.newProperty&&console.warn("This property is deprecated please use web3."+e.newProperty+" instead."),_.manager.send({method:e.setter,params:[t],inputFormatter:e.inputFormatter})}),r.enumerable=!e.newProperty,n.length>1?(t[n[0]]||(t[n[0]]={}),Object.defineProperty(t[n[0]],n[1],r)):Object.defineProperty(t,e.name,r)})},y=function(t,e,n,r){_.manager.startPolling({method:t,params:[e]},e,n,r)},b=function(t){_.manager.stopPolling(t)},v={startPolling:y.bind(null,"eth_getFilterChanges"),stopPolling:b},w={startPolling:y.bind(null,"shh_getFilterChanges"),stopPolling:b},_={version:{api:n.version},manager:f(),providers:{},setProvider:function(t){_.manager.setProvider(t)},reset:function(){_.manager.reset()},toHex:c.toHex,toAscii:c.toAscii,fromAscii:c.fromAscii,toDecimal:c.toDecimal,fromDecimal:c.fromDecimal,toBigNumber:c.toBigNumber,toWei:c.toWei,fromWei:c.fromWei,isAddress:c.isAddress,net:{},eth:{contractFromAbi:function(t){return console.warn("Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead."),function(e){e=e||"0xc6d9d2cd449a754c494264e1809c50e34d64562b";var n=_.eth.contract(e,t);return n.address=e,n}},filter:function(t,e,n){return t._isEvent?t(e,n):s(t,v,l.outputLogFormatter)},watch:function(t,e,n){return console.warn("eth.watch() is deprecated please use eth.filter() instead."),this.filter(t,e,n)}},db:{},shh:{filter:function(t){return s(t,w,l.outputPostFormatter)},watch:function(t){return console.warn("shh.watch() is deprecated please use shh.filter() instead."),this.filter(t)}}};Object.defineProperty(_.eth,"defaultBlock",{get:function(){return p.ETH_DEFAULTBLOCK},set:function(t){return p.ETH_DEFAULTBLOCK=t,p.ETH_DEFAULTBLOCK}}),h(_,m),g(_,d),h(_.net,r.methods),g(_.net,r.properties),h(_.eth,o.methods),g(_.eth,o.properties),h(_.db,i.methods()),h(_.shh,a.methods()),h(v,u.eth()),h(w,u.shh()),e.exports=_},{"../version.json":21,"./solidity/formatters":2,"./utils/config":4,"./utils/utils":5,"./web3/db":8,"./web3/eth":9,"./web3/filter":11,"./web3/net":15,"./web3/requestmanager":17,"./web3/shh":18,"./web3/watches":20}],7:[function(t,e){function n(t,e){t.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 n={};return c(n),l(n,t,e),f(n,t,e),p(n,t,e),n}var r=t("../web3"),o=t("../solidity/abi"),i=t("../utils/utils"),a=t("./event"),u=t("./signature"),s=function(t){r._currentContractAbi=t.abi,r._currentContractAddress=t.address,r._currentContractMethodName=t.method,r._currentContractMethodParams=t.params},c=function(t){t.call=function(e){return t._isTransaction=!1,t._options=e,t},t.sendTransaction=function(e){return t._isTransaction=!0,t._options=e,t},t.transact=function(e){return console.warn("myContract.transact() is deprecated please use myContract.sendTransaction() instead."),t.sendTransaction(e)},t._options={},["gas","gasPrice","value","from"].forEach(function(e){t[e]=function(n){return t._options[e]=n,t}})},l=function(t,e,n){var a=o.inputParser(e),c=o.outputParser(e);i.filterFunctions(e).forEach(function(o){var l=i.extractDisplayName(o.name),f=i.extractTypeName(o.name),p=function(){var i=Array.prototype.slice.call(arguments),p=u.functionSignatureFromAscii(o.name),m=a[l][f].apply(null,i),d=t._options||{};d.to=n,d.data=p+m;var h=t._isTransaction===!0||t._isTransaction!==!1&&!o.constant,g=d.collapse!==!1;if(t._options={},t._isTransaction=null,h)return s({abi:e,address:n,method:o.name,params:i}),void r.eth.sendTransaction(d);var y=r.eth.call(d),b=c[l][f](y);return g&&(1===b.length?b=b[0]:0===b.length&&(b=null)),b};void 0===t[l]&&(t[l]=p),t[l][f]=p})},f=function(t,e,n){t.address=n,t._onWatchEventResult=function(t){var n=event.getMatchingEvent(i.filterEvents(e)),r=a.outputParser(n);return r(t)},Object.defineProperty(t,"topics",{get:function(){return i.filterEvents(e).map(function(t){return u.eventSignatureFromAscii(t.name)})}})},p=function(t,e,n){i.filterEvents(e).forEach(function(e){var o=function(){var t=Array.prototype.slice.call(arguments),o=u.eventSignatureFromAscii(e.name),i=a.inputParser(n,o,e),s=i.apply(null,t),c=function(t){var n=a.outputParser(e);return n(t)};return r.eth.filter(s,void 0,void 0,c)};o._isEvent=!0;var s=i.extractDisplayName(e.name),c=i.extractTypeName(e.name);void 0===t[s]&&(t[s]=o),t[s][c]=o})},m=function(t){return t instanceof Array&&1===arguments.length?n.bind(null,t):(console.warn("Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead."),new n(arguments[1],arguments[0]))};e.exports=m},{"../solidity/abi":1,"../utils/utils":5,"../web3":6,"./event":10,"./signature":19}],8:[function(t,e){var n=function(){return[{name:"putString",call:"db_putString"},{name:"getString",call:"db_getString"},{name:"putHex",call:"db_putHex"},{name:"getHex",call:"db_getHex"}]};e.exports={methods:n}},{}],9:[function(t,e){var n=t("./formatters"),r=t("../utils/utils"),o=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockByHash":"eth_getBlockByNumber"},i=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getTransactionByBlockHashAndIndex":"eth_getTransactionByBlockNumberAndIndex"},a=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleByBlockHashAndIndex":"eth_getUncleByBlockNumberAndIndex"},u=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getBlockTransactionCountByHash":"eth_getBlockTransactionCountByNumber"},s=function(t){return r.isString(t[0])&&0===t[0].indexOf("0x")?"eth_getUncleCountByBlockHash":"eth_getUncleCountByBlockNumber"},c=[{name:"getBalance",call:"eth_getBalance",addDefaultblock:2,outputFormatter:n.convertToBigNumber},{name:"getStorageAt",call:"eth_getStorageAt",addDefaultblock:3,inputFormatter:r.toHex},{name:"getCode",call:"eth_getCode",addDefaultblock:2},{name:"getBlock",call:o,outputFormatter:n.outputBlockFormatter,inputFormatter:[r.toHex,function(t){return t?!0:!1}]},{name:"getUncle",call:a,outputFormatter:n.outputBlockFormatter,inputFormatter:[r.toHex,r.toHex,function(t){return t?!0:!1}]},{name:"getCompilers",call:"eth_getCompilers"},{name:"getBlockTransactionCount",call:u,outputFormatter:r.toDecimal,inputFormatter:r.toHex},{name:"getBlockUncleCount",call:s,outputFormatter:r.toDecimal,inputFormatter:r.toHex},{name:"getTransaction",call:"eth_getTransactionByHash",outputFormatter:n.outputTransactionFormatter},{name:"getTransactionFromBlock",call:i,outputFormatter:n.outputTransactionFormatter,inputFormatter:r.toHex},{name:"getTransactionCount",call:"eth_getTransactionCount",addDefaultblock:2,outputFormatter:r.toDecimal},{name:"sendTransaction",call:"eth_sendTransaction",inputFormatter:n.inputTransactionFormatter},{name:"call",call:"eth_call",addDefaultblock:2,inputFormatter:n.inputCallFormatter},{name:"compile.solidity",call:"eth_compileSolidity"},{name:"compile.lll",call:"eth_compileLLL",inputFormatter:r.toHex},{name:"compile.serpent",call:"eth_compileSerpent",inputFormatter:r.toHex},{name:"flush",call:"eth_flush"},{name:"balanceAt",call:"eth_balanceAt",newMethod:"eth.getBalance"},{name:"stateAt",call:"eth_stateAt",newMethod:"eth.getStorageAt"},{name:"storageAt",call:"eth_storageAt",newMethod:"eth.getStorage"},{name:"countAt",call:"eth_countAt",newMethod:"eth.getTransactionCount"},{name:"codeAt",call:"eth_codeAt",newMethod:"eth.getCode"},{name:"transact",call:"eth_transact",newMethod:"eth.sendTransaction"},{name:"block",call:o,newMethod:"eth.getBlock"},{name:"transaction",call:i,newMethod:"eth.getTransaction"},{name:"uncle",call:a,newMethod:"eth.getUncle"},{name:"compilers",call:"eth_compilers",newMethod:"eth.getCompilers"},{name:"solidity",call:"eth_solidity",newMethod:"eth.compile.solidity"},{name:"lll",call:"eth_lll",newMethod:"eth.compile.lll"},{name:"serpent",call:"eth_serpent",newMethod:"eth.compile.serpent"},{name:"transactionCount",call:u,newMethod:"eth.getBlockTransactionCount"},{name:"uncleCount",call:s,newMethod:"eth.getBlockUncleCount"},{name:"logs",call:"eth_logs"}],l=[{name:"coinbase",getter:"eth_coinbase"},{name:"mining",getter:"eth_mining"},{name:"gasPrice",getter:"eth_gasPrice",outputFormatter:n.convertToBigNumber},{name:"accounts",getter:"eth_accounts"},{name:"blockNumber",getter:"eth_blockNumber",outputFormatter:r.toDecimal},{name:"listening",getter:"net_listening",setter:"eth_setListening",newProperty:"net.listening"},{name:"peerCount",getter:"net_peerCount",newProperty:"net.peerCount"},{name:"number",getter:"eth_number",newProperty:"eth.blockNumber"}];e.exports={methods:c,properties:l}},{"../utils/utils":5,"./formatters":12}],10:[function(t,e){var n=t("../solidity/abi"),r=t("../utils/utils"),o=t("./signature"),i=function(t,e){return t.filter(function(t){return t.indexed===e})},a=function(t,e){var n=r.findIndex(t,function(t){return t.name===e});return-1===n?void console.error("indexed param with name "+e+" not found"):t[n]},u=function(t,e){return Object.keys(e).map(function(r){var o=[a(i(t.inputs,!0),r)],u=e[r];return u instanceof Array?u.map(function(t){return n.formatInput(o,[t])}):n.formatInput(o,[u])})},s=function(t,e,n){return function(r,o){var i=o||{};return i.address=t,i.topics=[],i.topics.push(e),r&&(i.topics=i.topics.concat(u(n,r))),i}},c=function(t,e,n){var r=e.slice(),o=n.slice();return t.reduce(function(t,e){var n;return n=e.indexed?r.splice(0,1)[0]:o.splice(0,1)[0],t[e.name]=n,t},{})},l=function(t){return function(e){var o={event:r.extractDisplayName(t.name),number:e.number,hash:e.hash,args:{}};if(e.topics=e.topic,!e.topics)return o;var a=i(t.inputs,!0),u="0x"+e.topics.slice(1,e.topics.length).map(function(t){return t.slice(2)}).join(""),s=n.formatOutput(a,u),l=i(t.inputs,!1),f=n.formatOutput(l,e.data);return o.args=c(t.inputs,s,f),o}},f=function(t,e){for(var n=0;n 1) {
- if(!obj[objectMethods[0]])
- obj[objectMethods[0]] = {};
-
- obj[objectMethods[0]][objectMethods[1]] = callFunction;
-
- } else {
-
- obj[objectMethods[0]] = callFunction;
- }
-
+ method.attachToObject(obj);
});
};
@@ -1170,173 +1186,53 @@ var setupMethods = function (obj, methods) {
/// setups api calls for these properties
var setupProperties = function (obj, properties) {
properties.forEach(function (property) {
- var objectProperties = property.name.split('.'),
- proto = {};
-
- proto.get = function () {
-
- // show deprecated warning
- if(property.newProperty)
- console.warn('This property is deprecated please use web3.'+ property.newProperty +' instead.');
-
-
- return web3.manager.send({
- method: property.getter,
- outputFormatter: property.outputFormatter
- });
- };
-
- if (property.setter) {
- proto.set = function (val) {
-
- // show deprecated warning
- if(property.newProperty)
- console.warn('This property is deprecated please use web3.'+ property.newProperty +' instead.');
-
- return web3.manager.send({
- method: property.setter,
- params: [val],
- inputFormatter: property.inputFormatter
- });
- };
- }
-
- proto.enumerable = !property.newProperty;
-
- if(objectProperties.length > 1) {
- if(!obj[objectProperties[0]])
- obj[objectProperties[0]] = {};
-
- Object.defineProperty(obj[objectProperties[0]], objectProperties[1], proto);
- } else
- Object.defineProperty(obj, property.name, proto);
-
+ property.attachToObject(obj);
});
};
+/// setups web3 object, and it's in-browser executed methods
+var web3 = {};
+web3.providers = {};
+web3.version = {};
+web3.version.api = version.version;
+web3.eth = {};
+
/*jshint maxparams:4 */
-var startPolling = function (method, id, callback, uninstall) {
- web3.manager.startPolling({
- method: method,
- params: [id]
- }, id, callback, uninstall);
-};
-/*jshint maxparams:3 */
+web3.eth.filter = function (fil, eventParams, options, formatter) {
-var stopPolling = function (id) {
- web3.manager.stopPolling(id);
-};
+ // if its event, treat it differently
+ // TODO: simplify and remove
+ if (fil._isEvent) {
+ return fil(eventParams, options);
+ }
-var ethWatch = {
- startPolling: startPolling.bind(null, 'eth_getFilterChanges'),
- stopPolling: stopPolling
+ // what outputLogFormatter? that's wrong
+ //return new Filter(fil, watches.eth(), formatters.outputLogFormatter);
+ return new Filter(fil, watches.eth(), formatter || formatters.outputLogFormatter);
};
+/*jshint maxparams:3 */
-var shhWatch = {
- startPolling: startPolling.bind(null, 'shh_getFilterChanges'),
- stopPolling: stopPolling
+web3.shh = {};
+web3.shh.filter = function (fil) {
+ return new Filter(fil, watches.shh(), formatters.outputPostFormatter);
};
-
-/// setups web3 object, and it's in-browser executed methods
-var web3 = {
-
- version: {
- api: version.version
- },
-
- manager: requestManager(),
- providers: {},
-
- setProvider: function (provider) {
- web3.manager.setProvider(provider);
- },
-
- /// Should be called to reset state of web3 object
- /// Resets everything except manager
- reset: function () {
- web3.manager.reset();
- },
-
- /// @returns hex string of the input
- toHex: utils.toHex,
-
- /// @returns ascii string representation of hex value prefixed with 0x
- toAscii: utils.toAscii,
-
- /// @returns hex representation (prefixed by 0x) of ascii string
- fromAscii: utils.fromAscii,
-
- /// @returns decimal representaton of hex value prefixed by 0x
- toDecimal: utils.toDecimal,
-
- /// @returns hex representation (prefixed by 0x) of decimal value
- fromDecimal: utils.fromDecimal,
-
- /// @returns a BigNumber object
- toBigNumber: utils.toBigNumber,
-
- toWei: utils.toWei,
- fromWei: utils.fromWei,
- isAddress: utils.isAddress,
-
- // provide network information
- net: {
- // peerCount:
- },
-
-
- /// eth object prototype
- eth: {
- // DEPRECATED
- contractFromAbi: function (abi) {
- console.warn('Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead.');
-
- 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;
- };
- },
-
- /// @param filter may be a string, object or event
- /// @param eventParams is optional, this is an object with optional event eventParams params
- /// @param options is optional, this is an object with optional event options ('max'...)
- /*jshint maxparams:4 */
- filter: function (fil, eventParams, options) {
-
- // if its event, treat it differently
- if (fil._isEvent)
- return fil(eventParams, options);
-
- return filter(fil, ethWatch, formatters.outputLogFormatter);
- },
- // DEPRECATED
- watch: function (fil, eventParams, options) {
- console.warn('eth.watch() is deprecated please use eth.filter() instead.');
- return this.filter(fil, eventParams, options);
- }
- /*jshint maxparams:3 */
- },
-
- /// db object prototype
- db: {},
-
- /// shh object prototype
- shh: {
- /// @param filter may be a string, object or event
- filter: function (fil) {
- return filter(fil, shhWatch, formatters.outputPostFormatter);
- },
- // DEPRECATED
- watch: function (fil) {
- console.warn('shh.watch() is deprecated please use shh.filter() instead.');
- return this.filter(fil);
- }
- }
+web3.net = {};
+web3.db = {};
+web3.setProvider = function (provider) {
+ RequestManager.getInstance().setProvider(provider);
};
-
+web3.reset = function () {
+ RequestManager.getInstance().reset();
+};
+web3.toHex = utils.toHex;
+web3.toAscii = utils.toAscii;
+web3.fromAscii = utils.fromAscii;
+web3.toDecimal = utils.toDecimal;
+web3.fromDecimal = utils.fromDecimal;
+web3.toBigNumber = utils.toBigNumber;
+web3.toWei = utils.toWei;
+web3.fromWei = utils.fromWei;
+web3.isAddress = utils.isAddress;
// ADD defaultblock
Object.defineProperty(web3.eth, 'defaultBlock', {
@@ -1357,15 +1253,13 @@ setupMethods(web3.net, net.methods);
setupProperties(web3.net, net.properties);
setupMethods(web3.eth, eth.methods);
setupProperties(web3.eth, eth.properties);
-setupMethods(web3.db, db.methods());
-setupMethods(web3.shh, shh.methods());
-setupMethods(ethWatch, watches.eth());
-setupMethods(shhWatch, watches.shh());
+setupMethods(web3.db, db.methods);
+setupMethods(web3.shh, shh.methods);
module.exports = web3;
-},{"../version.json":21,"./solidity/formatters":2,"./utils/config":4,"./utils/utils":5,"./web3/db":8,"./web3/eth":9,"./web3/filter":11,"./web3/net":15,"./web3/requestmanager":17,"./web3/shh":18,"./web3/watches":20}],7:[function(require,module,exports){
+},{"./utils/config":5,"./utils/utils":6,"./version.json":7,"./web3/db":10,"./web3/eth":12,"./web3/filter":14,"./web3/formatters":15,"./web3/method":18,"./web3/net":19,"./web3/property":20,"./web3/requestmanager":22,"./web3/shh":23,"./web3/watches":25}],9:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -1394,15 +1288,6 @@ var utils = require('../utils/utils');
var eventImpl = require('./event');
var signature = require('./signature');
-var exportNatspecGlobals = function (vars) {
- // it's used byt natspec.js
- // TODO: figure out better way to solve this
- web3._currentContractAbi = vars.abi;
- web3._currentContractAddress = vars.address;
- web3._currentContractMethodName = vars.method;
- web3._currentContractMethodParams = vars.params;
-};
-
var addFunctionRelatedPropertiesToContract = function (contract) {
contract.call = function (options) {
@@ -1411,28 +1296,11 @@ var addFunctionRelatedPropertiesToContract = function (contract) {
return contract;
};
-
contract.sendTransaction = function (options) {
contract._isTransaction = true;
contract._options = options;
return contract;
};
- // DEPRECATED
- contract.transact = function (options) {
-
- console.warn('myContract.transact() is deprecated please use myContract.sendTransaction() instead.');
-
- return contract.sendTransaction(options);
- };
-
- contract._options = {};
- ['gas', 'gasPrice', 'value', 'from'].forEach(function(p) {
- contract[p] = function (v) {
- contract._options[p] = v;
- return contract;
- };
- });
-
};
var addFunctionsToContract = function (contract, desc, address) {
@@ -1464,13 +1332,6 @@ var addFunctionsToContract = function (contract, desc, address) {
if (isTransaction) {
- exportNatspecGlobals({
- abi: desc,
- address: address,
- method: method.name,
- params: params
- });
-
// transactions do not have any output, cause we do not know, when they will be processed
web3.eth.sendTransaction(options);
return;
@@ -1527,7 +1388,7 @@ var addEventsToContract = function (contract, desc, address) {
var parser = eventImpl.outputParser(e);
return parser(data);
};
- return web3.eth.filter(o, undefined, undefined, outputFormatter);
+ return web3.eth.filter(o, undefined, undefined, outputFormatter);
};
// this property should be used by eth.filter to check if object is an event
@@ -1571,17 +1432,7 @@ var addEventsToContract = function (contract, desc, address) {
var contract = function (abi) {
// return prototype
- if(abi instanceof Array && arguments.length === 1) {
- return Contract.bind(null, abi);
-
- // deprecated: auto initiate contract
- } else {
-
- console.warn('Initiating a contract like this is deprecated please use var MyContract = eth.contract(abi); new MyContract(address); instead.');
-
- return new Contract(arguments[1], arguments[0]);
- }
-
+ return Contract.bind(null, abi);
};
function Contract(abi, address) {
@@ -1610,7 +1461,7 @@ function Contract(abi, address) {
module.exports = contract;
-},{"../solidity/abi":1,"../utils/utils":5,"../web3":6,"./event":10,"./signature":19}],8:[function(require,module,exports){
+},{"../solidity/abi":1,"../utils/utils":6,"../web3":8,"./event":13,"./signature":24}],10:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -1633,22 +1484,42 @@ module.exports = contract;
* @date 2015
*/
+var Method = require('./method');
-/// @returns an array of objects describing web3.db api methods
-var methods = function () {
- return [
- { name: 'putString', call: 'db_putString'},
- { name: 'getString', call: 'db_getString'},
- { name: 'putHex', call: 'db_putHex'},
- { name: 'getHex', call: 'db_getHex'}
- ];
-};
+var putString = new Method({
+ name: 'putString',
+ call: 'db_putString',
+ params: 3
+});
+
+
+var getString = new Method({
+ name: 'getString',
+ call: 'db_getString',
+ params: 2
+});
+
+var putHex = new Method({
+ name: 'putHex',
+ call: 'db_putHex',
+ params: 3
+});
+
+var getHex = new Method({
+ name: 'getHex',
+ call: 'db_getHex',
+ params: 2
+});
+
+var methods = [
+ putString, getString, putHex, getHex
+];
module.exports = {
methods: methods
};
-},{}],9:[function(require,module,exports){
+},{"./method":18}],11:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -1665,10 +1536,50 @@ module.exports = {
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see .
*/
-/** @file eth.js
- * @authors:
- * Marek Kotewicz
- * Fabian Vogelsteller
+/**
+ * @file errors.js
+ * @author Marek Kotewicz
+ * @date 2015
+ */
+
+var utils = require('../utils/utils');
+
+module.exports = {
+ InvalidNumberOfParams: new Error('Invalid number of input parameters'),
+ InvalidProvider: new Error('Providor not set or invalid'),
+ InvalidResponse: function(result){
+ var message = 'Invalid JSON RPC response';
+
+ if(utils.isObject(result) && result.error && result.error.message) {
+ message = result.error.message;
+ }
+
+ return new Error(message);
+ }
+};
+
+
+},{"../utils/utils":6}],12:[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 .
+*/
+/**
+ * @file eth.js
+ * @author Marek Kotewicz
+ * @author Fabian Vogelsteller
* @date 2015
*/
@@ -1686,10 +1597,11 @@ module.exports = {
* {
* name: 'getBlock',
* call: blockCall,
+ * params: 2,
* outputFormatter: formatters.outputBlockFormatter,
* inputFormatter: [ // can be a formatter funciton or an array of functions. Where each item in the array will be used for one parameter
* utils.toHex, // formats paramter 1
- * function(param){ if(!param) return false; } // formats paramter 2
+ * function(param){ return !!param; } // formats paramter 2
* ]
* },
*
@@ -1697,10 +1609,12 @@ module.exports = {
* @constructor
*/
+"use strict";
var formatters = require('./formatters');
var utils = require('../utils/utils');
-
+var Method = require('./method');
+var Property = require('./property');
var blockCall = function (args) {
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
@@ -1723,82 +1637,185 @@ var uncleCountCall = function (args) {
};
/// @returns an array of objects describing web3.eth api methods
+
+var getBalance = new Method({
+ name: 'getBalance',
+ call: 'eth_getBalance',
+ params: 2,
+ inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter],
+ outputFormatter: formatters.outputBigNumberFormatter
+});
+
+var getStorageAt = new Method({
+ name: 'getStorageAt',
+ call: 'eth_getStorageAt',
+ params: 3,
+ inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
+});
+
+var getCode = new Method({
+ name: 'getCode',
+ call: 'eth_getCode',
+ params: 2,
+ inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter]
+});
+
+var getBlock = new Method({
+ name: 'getBlock',
+ call: blockCall,
+ params: 2,
+ inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
+ outputFormatter: formatters.outputBlockFormatter
+});
+
+var getUncle = new Method({
+ name: 'getUncle',
+ call: uncleCall,
+ params: 3,
+ inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex, function (val) { return !!val; }],
+ outputFormatter: formatters.outputBlockFormatter,
+
+});
+
+var getCompilers = new Method({
+ name: 'getCompilers',
+ call: 'eth_getCompilers',
+ params: 0
+});
+
+var getBlockTransactionCount = new Method({
+ name: 'getBlockTransactionCount',
+ call: getBlockTransactionCountCall,
+ params: 1,
+ inputFormatter: [formatters.inputBlockNumberFormatter],
+ outputFormatter: utils.toDecimal
+});
+
+var getBlockUncleCount = new Method({
+ name: 'getBlockUncleCount',
+ call: uncleCountCall,
+ params: 1,
+ inputFormatter: [formatters.inputBlockNumberFormatter],
+ outputFormatter: utils.toDecimal
+});
+
+var getTransaction = new Method({
+ name: 'getTransaction',
+ call: 'eth_getTransactionByHash',
+ params: 1,
+ outputFormatter: formatters.outputTransactionFormatter
+});
+
+var getTransactionFromBlock = new Method({
+ name: 'getTransactionFromBlock',
+ call: transactionFromBlockCall,
+ params: 2,
+ inputFormatter: [utils.toHex, utils.toHex],
+ outputFormatter: formatters.outputTransactionFormatter
+});
+
+var getTransactionCount = new Method({
+ name: 'getTransactionCount',
+ call: 'eth_getTransactionCount',
+ params: 2,
+ inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
+ outputFormatter: utils.toDecimal
+});
+
+var sendTransaction = new Method({
+ name: 'sendTransaction',
+ call: 'eth_sendTransaction',
+ params: 1,
+ inputFormatter: [formatters.inputTransactionFormatter]
+});
+
+var call = new Method({
+ name: 'call',
+ call: 'eth_call',
+ params: 2,
+ inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter]
+});
+
+var compileSolidity = new Method({
+ name: 'compile.solidity',
+ call: 'eth_compileSolidity',
+ params: 1
+});
+
+var compileLLL = new Method({
+ name: 'compile.lll',
+ call: 'eth_compileLLL',
+ params: 1
+});
+
+var compileSerpent = new Method({
+ name: 'compile.serpent',
+ call: 'eth_compileSerpent',
+ params: 1
+});
+
+var flush = new Method({
+ name: 'flush',
+ call: 'eth_flush',
+ params: 0
+});
+
var methods = [
- { name: 'getBalance', call: 'eth_getBalance', addDefaultblock: 2,
- outputFormatter: formatters.convertToBigNumber},
- { name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3,
- inputFormatter: utils.toHex},
- { name: 'getCode', call: 'eth_getCode', addDefaultblock: 2},
- { name: 'getBlock', call: blockCall,
- outputFormatter: formatters.outputBlockFormatter,
- inputFormatter: [utils.toHex, function(param){ return (!param) ? false : true; }]},
- { name: 'getUncle', call: uncleCall,
- outputFormatter: formatters.outputBlockFormatter,
- inputFormatter: [utils.toHex, utils.toHex, function(param){ return (!param) ? false : true; }]},
- { name: 'getCompilers', call: 'eth_getCompilers' },
- { name: 'getBlockTransactionCount', call: getBlockTransactionCountCall,
- outputFormatter: utils.toDecimal,
- inputFormatter: utils.toHex },
- { name: 'getBlockUncleCount', call: uncleCountCall,
- outputFormatter: utils.toDecimal,
- inputFormatter: utils.toHex },
- { name: 'getTransaction', call: 'eth_getTransactionByHash',
- outputFormatter: formatters.outputTransactionFormatter },
- { name: 'getTransactionFromBlock', call: transactionFromBlockCall,
- outputFormatter: formatters.outputTransactionFormatter,
- inputFormatter: utils.toHex },
- { name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2,
- outputFormatter: utils.toDecimal},
- { name: 'sendTransaction', call: 'eth_sendTransaction',
- inputFormatter: formatters.inputTransactionFormatter },
- { name: 'call', call: 'eth_call', addDefaultblock: 2,
- inputFormatter: formatters.inputCallFormatter },
- { name: 'compile.solidity', call: 'eth_compileSolidity' },
- { name: 'compile.lll', call: 'eth_compileLLL', inputFormatter: utils.toHex },
- { name: 'compile.serpent', call: 'eth_compileSerpent', inputFormatter: utils.toHex },
- { name: 'flush', call: 'eth_flush' },
-
- // deprecated methods
- { name: 'balanceAt', call: 'eth_balanceAt', newMethod: 'eth.getBalance' },
- { name: 'stateAt', call: 'eth_stateAt', newMethod: 'eth.getStorageAt' },
- { name: 'storageAt', call: 'eth_storageAt', newMethod: 'eth.getStorage' },
- { name: 'countAt', call: 'eth_countAt', newMethod: 'eth.getTransactionCount' },
- { name: 'codeAt', call: 'eth_codeAt', newMethod: 'eth.getCode' },
- { name: 'transact', call: 'eth_transact', newMethod: 'eth.sendTransaction' },
- { name: 'block', call: blockCall, newMethod: 'eth.getBlock' },
- { name: 'transaction', call: transactionFromBlockCall, newMethod: 'eth.getTransaction' },
- { name: 'uncle', call: uncleCall, newMethod: 'eth.getUncle' },
- { name: 'compilers', call: 'eth_compilers', newMethod: 'eth.getCompilers' },
- { name: 'solidity', call: 'eth_solidity', newMethod: 'eth.compile.solidity' },
- { name: 'lll', call: 'eth_lll', newMethod: 'eth.compile.lll' },
- { name: 'serpent', call: 'eth_serpent', newMethod: 'eth.compile.serpent' },
- { name: 'transactionCount', call: getBlockTransactionCountCall, newMethod: 'eth.getBlockTransactionCount' },
- { name: 'uncleCount', call: uncleCountCall, newMethod: 'eth.getBlockUncleCount' },
- { name: 'logs', call: 'eth_logs' }
+ getBalance,
+ getStorageAt,
+ getCode,
+ getBlock,
+ getUncle,
+ getCompilers,
+ getBlockTransactionCount,
+ getBlockUncleCount,
+ getTransaction,
+ getTransactionFromBlock,
+ getTransactionCount,
+ call,
+ sendTransaction,
+ compileSolidity,
+ compileLLL,
+ compileSerpent,
+ flush
];
/// @returns an array of objects describing web3.eth api properties
+
+
+
var properties = [
- { name: 'coinbase', getter: 'eth_coinbase'},
- { name: 'mining', getter: 'eth_mining'},
- { name: 'gasPrice', getter: 'eth_gasPrice', outputFormatter: formatters.convertToBigNumber},
- { name: 'accounts', getter: 'eth_accounts' },
- { name: 'blockNumber', getter: 'eth_blockNumber', outputFormatter: utils.toDecimal},
-
- // deprecated properties
- { name: 'listening', getter: 'net_listening', setter: 'eth_setListening', newProperty: 'net.listening'},
- { name: 'peerCount', getter: 'net_peerCount', newProperty: 'net.peerCount'},
- { name: 'number', getter: 'eth_number', newProperty: 'eth.blockNumber'}
+ new Property({
+ name: 'coinbase',
+ getter: 'eth_coinbase'
+ }),
+ new Property({
+ name: 'mining',
+ getter: 'eth_mining'
+ }),
+ new Property({
+ name: 'gasPrice',
+ getter: 'eth_gasPrice',
+ outputFormatter: formatters.inputNumberFormatter
+ }),
+ new Property({
+ name: 'accounts',
+ getter: 'eth_accounts'
+ }),
+ new Property({
+ name: 'blockNumber',
+ getter: 'eth_blockNumber',
+ outputFormatter: utils.toDecimal
+ })
];
-
module.exports = {
methods: methods,
properties: properties
};
-},{"../utils/utils":5,"./formatters":12}],10:[function(require,module,exports){
+},{"../utils/utils":6,"./formatters":15,"./method":18,"./property":20}],13:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -1858,7 +1875,7 @@ var indexedParamsToTopics = function (event, indexed) {
return abi.formatInput(inputs, [v]);
});
}
- return abi.formatInput(inputs, [value]);
+ return '0x' + abi.formatInput(inputs, [value]);
});
};
@@ -1902,10 +1919,10 @@ var outputParser = function (event) {
args: {}
};
- output.topics = output.topic; // fallback for go-ethereum
if (!output.topics) {
return result;
}
+ output.data = output.data || '';
var indexedOutputs = filterInputs(event.inputs, true);
var indexedData = "0x" + output.topics.slice(1, output.topics.length).map(function (topics) { return topics.slice(2); }).join("");
@@ -1938,7 +1955,7 @@ module.exports = {
};
-},{"../solidity/abi":1,"../utils/utils":5,"./signature":19}],11:[function(require,module,exports){
+},{"../solidity/abi":1,"../utils/utils":6,"./signature":24}],14:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -1965,153 +1982,92 @@ module.exports = {
* @date 2014
*/
+var RequestManager = require('./requestmanager');
+var formatters = require('./formatters');
var utils = require('../utils/utils');
-/// Should be called to check if filter implementation is valid
-/// @returns true if it is, otherwise false
-var implementationIsValid = function (i) {
- return !!i &&
- typeof i.newFilter === 'function' &&
- typeof i.getLogs === 'function' &&
- typeof i.uninstallFilter === 'function' &&
- typeof i.startPolling === 'function' &&
- typeof i.stopPolling === 'function';
-};
-
/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
/// @param should be string or object
/// @returns options string or object
var getOptions = function (options) {
- /*jshint maxcomplexity:9 */
- if (typeof options === 'string') {
+ if (utils.isString(options)) {
return options;
}
options = options || {};
- if (options.topic) {
- console.warn('"topic" is deprecated, is "topics" instead');
- options.topics = options.topic;
- }
-
- if (options.earliest) {
- console.warn('"earliest" is deprecated, is "fromBlock" instead');
- options.fromBlock = options.earliest;
- }
-
- if (options.latest) {
- console.warn('"latest" is deprecated, is "toBlock" instead');
- options.toBlock = options.latest;
- }
-
// make sure topics, get converted to hex
- if(options.topics instanceof Array) {
- options.topics = options.topics.map(function(topic){
- return utils.toHex(topic);
- });
- }
-
- var asBlockNumber = function(n) {
- if (n == null)
- return null;
- if (n == 'latest' || n == 'pending')
- return n;
- return utils.toHex(n);
- };
+ options.topics = options.topics || [];
+ options.topics = options.topics.map(function(topic){
+ return utils.toHex(topic);
+ });
- // evaluate lazy properties
+ // lazy load
return {
- fromBlock: asBlockNumber(options.fromBlock),
- toBlock: asBlockNumber(options.toBlock),
+ topics: options.topics,
to: options.to,
address: options.address,
- topics: options.topics
- };
+ fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
+ toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
+ };
};
-/// Should be used when we want to watch something
-/// it's using inner polling mechanism and is notified about changes
-/// @param options are filter options
-/// @param implementation, an abstract polling implementation
-/// @param formatter (optional), callback function which formats output before 'real' callback
-var filter = function(options, implementation, formatter) {
- if (!implementationIsValid(implementation)) {
- console.error('filter implemenation is invalid');
- return;
- }
+var Filter = function (options, methods, formatter) {
+ var implementation = {};
+ methods.forEach(function (method) {
+ method.attachToObject(implementation);
+ });
+ this.options = getOptions(options);
+ this.implementation = implementation;
+ this.callbacks = [];
+ this.formatter = formatter;
+ this.filterId = this.implementation.newFilter(this.options);
+};
+
+Filter.prototype.watch = function (callback) {
+ this.callbacks.push(callback);
+ var self = this;
- options = getOptions(options);
- var callbacks = [];
- var filterId = implementation.newFilter(options);
+ var onMessage = function (error, messages) {
+ if (error) {
+ return self.callbacks.forEach(function (callback) {
+ callback(error);
+ });
+ }
- // call the callbacks
- var onMessages = function (messages) {
messages.forEach(function (message) {
- message = formatter ? formatter(message) : message;
- callbacks.forEach(function (callback) {
- callback(message);
+ message = self.formatter ? self.formatter(message) : message;
+ self.callbacks.forEach(function (callback) {
+ callback(null, message);
});
});
};
- implementation.startPolling(filterId, onMessages, implementation.uninstallFilter);
-
- var watch = function(callback) {
- callbacks.push(callback);
- };
-
- var stopWatching = function() {
- implementation.stopPolling(filterId);
- implementation.uninstallFilter(filterId);
- callbacks = [];
- };
+ RequestManager.getInstance().startPolling({
+ method: this.implementation.poll.call,
+ params: [this.filterId],
+ }, this.filterId, onMessage, this.stopWatching.bind(this));
+};
- var get = function () {
- var results = implementation.getLogs(filterId);
+Filter.prototype.stopWatching = function () {
+ RequestManager.getInstance().stopPolling(this.filterId);
+ this.implementation.uninstallFilter(this.filterId);
+ this.callbacks = [];
+};
- return utils.isArray(results) ? results.map(function(message){
- return formatter ? formatter(message) : message;
- }) : results;
- };
-
- return {
- watch: watch,
- stopWatching: stopWatching,
- get: get,
-
- // DEPRECATED methods
- changed: function(){
- console.warn('watch().changed() is deprecated please use filter().watch() instead.');
- return watch.apply(this, arguments);
- },
- arrived: function(){
- console.warn('watch().arrived() is deprecated please use filter().watch() instead.');
- return watch.apply(this, arguments);
- },
- happened: function(){
- console.warn('watch().happened() is deprecated please use filter().watch() instead.');
- return watch.apply(this, arguments);
- },
- uninstall: function(){
- console.warn('watch().uninstall() is deprecated please use filter().stopWatching() instead.');
- return stopWatching.apply(this, arguments);
- },
- messages: function(){
- console.warn('watch().messages() is deprecated please use filter().get() instead.');
- return get.apply(this, arguments);
- },
- logs: function(){
- console.warn('watch().logs() is deprecated please use filter().get() instead.');
- return get.apply(this, arguments);
- }
- };
+Filter.prototype.get = function () {
+ var logs = this.implementation.getLogs(this.filterId);
+ var self = this;
+ return logs.map(function (log) {
+ return self.formatter ? self.formatter(log) : log;
+ });
};
-module.exports = filter;
+module.exports = Filter;
-},{"../utils/utils":5}],12:[function(require,module,exports){
+},{"../utils/utils":6,"./formatters":15,"./requestmanager":22}],15:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -2128,24 +2084,45 @@ module.exports = filter;
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see .
*/
-/** @file formatters.js
- * @authors:
- * Marek Kotewicz
- * Fabian Vogelsteller
+/**
+ * @file formatters.js
+ * @author Marek Kotewicz
+ * @author Fabian Vogelsteller
* @date 2015
*/
var utils = require('../utils/utils');
+var config = require('../utils/config');
/**
- * Should the input to a big number
+ * Should the format output to a big number
*
- * @method convertToBigNumber
+ * @method outputBigNumberFormatter
* @param {String|Number|BigNumber}
* @returns {BigNumber} object
*/
-var convertToBigNumber = function (value) {
- return utils.toBigNumber(value);
+var outputBigNumberFormatter = function (number) {
+ return utils.toBigNumber(number);
+};
+
+var isPredefinedBlockNumber = function (blockNumber) {
+ return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
+};
+
+var inputDefaultBlockNumberFormatter = function (blockNumber) {
+ if (blockNumber === undefined) {
+ return config.ETH_DEFAULTBLOCK;
+ }
+ return inputBlockNumberFormatter(blockNumber);
+};
+
+var inputBlockNumberFormatter = function (blockNumber) {
+ if (blockNumber === undefined) {
+ return undefined;
+ } else if (isPredefinedBlockNumber(blockNumber)) {
+ return blockNumber;
+ }
+ return utils.toHex(blockNumber);
};
/**
@@ -2163,11 +2140,13 @@ var inputTransactionFormatter = function (options){
delete options.code;
}
- ['gasPrice', 'gas', 'value'].forEach(function(key){
+ ['gasPrice', 'gas', 'value'].filter(function (key) {
+ return options[key] !== undefined;
+ }).forEach(function(key){
options[key] = utils.fromDecimal(options[key]);
});
- return options;
+ return options;
};
/**
@@ -2178,31 +2157,14 @@ var inputTransactionFormatter = function (options){
* @returns {Object} transaction
*/
var outputTransactionFormatter = function (tx){
+ tx.blockNumber = utils.toDecimal(tx.blockNumber);
+ tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
tx.gas = utils.toDecimal(tx.gas);
tx.gasPrice = utils.toBigNumber(tx.gasPrice);
tx.value = utils.toBigNumber(tx.value);
return tx;
};
-/**
- * Formats the input of a call and converts all values to HEX
- *
- * @method inputCallFormatter
- * @param {Object} transaction options
- * @returns object
-*/
-var inputCallFormatter = function (options){
-
- // make code -> data
- if (options.code) {
- options.data = options.code;
- delete options.code;
- }
-
- return options;
-};
-
-
/**
* Formats the output of a block to its proper values
*
@@ -2210,7 +2172,7 @@ var inputCallFormatter = function (options){
* @param {Object} block object
* @returns {Object} block object
*/
-var outputBlockFormatter = function(block){
+var outputBlockFormatter = function(block) {
// transform to number
block.gasLimit = utils.toDecimal(block.gasLimit);
@@ -2223,7 +2185,7 @@ var outputBlockFormatter = function(block){
block.difficulty = utils.toBigNumber(block.difficulty);
block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
- if(block.transactions instanceof Array) {
+ if (utils.isArray(block.transactions)) {
block.transactions.forEach(function(item){
if(!utils.isString(item))
return outputTransactionFormatter(item);
@@ -2240,7 +2202,11 @@ var outputBlockFormatter = function(block){
* @param {Object} log object
* @returns {Object} log
*/
-var outputLogFormatter = function(log){
+var outputLogFormatter = function(log) {
+ if (log === null) { // 'pending' && 'latest' filters are nulls
+ return null;
+ }
+
log.blockNumber = utils.toDecimal(log.blockNumber);
log.transactionIndex = utils.toDecimal(log.transactionIndex);
log.logIndex = utils.toDecimal(log.logIndex);
@@ -2248,7 +2214,6 @@ var outputLogFormatter = function(log){
return log;
};
-
/**
* Formats the input of a whisper post and converts all values to HEX
*
@@ -2256,22 +2221,22 @@ var outputLogFormatter = function(log){
* @param {Object} transaction object
* @returns {Object}
*/
-var inputPostFormatter = function(post){
+var inputPostFormatter = function(post) {
post.payload = utils.toHex(post.payload);
post.ttl = utils.fromDecimal(post.ttl);
post.priority = utils.fromDecimal(post.priority);
- if(!(post.topics instanceof Array))
+ if(!utils.isArray(post.topics)) {
post.topics = [post.topics];
-
+ }
// format the following options
post.topics = post.topics.map(function(topic){
return utils.fromAscii(topic);
});
- return post;
+ return post;
};
/**
@@ -2290,10 +2255,8 @@ var outputPostFormatter = function(post){
post.payloadRaw = post.payload;
post.payload = utils.toAscii(post.payload);
- if(post.payload.indexOf('{') === 0 || post.payload.indexOf('[') === 0) {
- try {
- post.payload = JSON.parse(post.payload);
- } catch (e) { }
+ if (utils.isJson(post.payload)) {
+ post.payload = JSON.parse(post.payload);
}
// format the following options
@@ -2305,18 +2268,19 @@ var outputPostFormatter = function(post){
};
module.exports = {
- convertToBigNumber: convertToBigNumber,
+ inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
+ inputBlockNumberFormatter: inputBlockNumberFormatter,
inputTransactionFormatter: inputTransactionFormatter,
+ inputPostFormatter: inputPostFormatter,
+ outputBigNumberFormatter: outputBigNumberFormatter,
outputTransactionFormatter: outputTransactionFormatter,
- inputCallFormatter: inputCallFormatter,
outputBlockFormatter: outputBlockFormatter,
outputLogFormatter: outputLogFormatter,
- inputPostFormatter: inputPostFormatter,
outputPostFormatter: outputPostFormatter
};
-},{"../utils/utils":5}],13:[function(require,module,exports){
+},{"../utils/config":5,"../utils/utils":6}],16:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -2341,53 +2305,45 @@ module.exports = {
* @date 2014
*/
-if ("build" !== 'build') {/*
- var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
-*/}
+"use strict";
+
+var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
var HttpProvider = function (host) {
- this.name = 'HTTP';
- this.handlers = [];
this.host = host || 'http://localhost:8080';
};
-HttpProvider.prototype.send = function (payload, callback) {
+HttpProvider.prototype.send = function (payload) {
var request = new XMLHttpRequest();
- // ASYNC
- if(typeof callback === 'function') {
- request.onreadystatechange = function() {
- if(request.readyState === 4) {
- var result = '';
- try {
- result = JSON.parse(request.responseText);
- } catch(error) {
- result = error;
- }
- callback(result, request.status);
- }
- };
+ request.open('POST', this.host, false);
+ request.send(JSON.stringify(payload));
- request.open('POST', this.host, true);
- request.send(JSON.stringify(payload));
+ // check request.status
+ // TODO: throw an error here! it cannot silently fail!!!
+ //if (request.status !== 200) {
+ //return;
+ //}
+ return JSON.parse(request.responseText);
+};
- // SYNC
- } else {
- request.open('POST', this.host, false);
- request.send(JSON.stringify(payload));
+HttpProvider.prototype.sendAsync = function (payload, callback) {
+ var request = new XMLHttpRequest();
+ request.onreadystatechange = function() {
+ if (request.readyState === 4) {
+ // TODO: handle the error properly here!!!
+ callback(null, JSON.parse(request.responseText));
+ }
+ };
- // check request.status
- if(request.status !== 200)
- return;
- return JSON.parse(request.responseText);
-
- }
+ request.open('POST', this.host, true);
+ request.send(JSON.stringify(payload));
};
module.exports = HttpProvider;
-},{}],14:[function(require,module,exports){
+},{"xmlhttprequest":4}],17:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -2410,13 +2366,33 @@ module.exports = HttpProvider;
* @date 2015
*/
-var messageId = 1;
+var Jsonrpc = function () {
+ // singleton pattern
+ if (arguments.callee._singletonInstance) {
+ return arguments.callee._singletonInstance;
+ }
+ arguments.callee._singletonInstance = this;
-/// Should be called to valid json create payload object
-/// @param method of jsonrpc call, required
-/// @param params, an array of method params, optional
-/// @returns valid jsonrpc payload object
-var toPayload = function (method, params) {
+ this.messageId = 1;
+};
+
+/**
+ * @return {Jsonrpc} singleton
+ */
+Jsonrpc.getInstance = function () {
+ var instance = new Jsonrpc();
+ return instance;
+};
+
+/**
+ * Should be called to valid json create payload object
+ *
+ * @method toPayload
+ * @param {Function} method of jsonrpc call, required
+ * @param {Array} params, an array of method params, optional
+ * @returns {Object} valid jsonrpc payload object
+ */
+Jsonrpc.prototype.toPayload = function (method, params) {
if (!method)
console.error('jsonrpc method should be specified!');
@@ -2424,13 +2400,18 @@ var toPayload = function (method, params) {
jsonrpc: '2.0',
method: method,
params: params || [],
- id: messageId++
- };
+ id: this.messageId++
+ };
};
-/// Should be called to check if jsonrpc response is valid
-/// @returns true if response is valid, otherwise false
-var isValidResponse = function (response) {
+/**
+ * Should be called to check if jsonrpc response is valid
+ *
+ * @method isValidResponse
+ * @param {Object}
+ * @returns {Boolean} true if response is valid, otherwise false
+ */
+Jsonrpc.prototype.isValidResponse = function (response) {
return !!response &&
!response.error &&
response.jsonrpc === '2.0' &&
@@ -2438,23 +2419,185 @@ var isValidResponse = function (response) {
response.result !== undefined; // only undefined is not valid json object
};
-/// Should be called to create batch payload object
-/// @param messages, an array of objects with method (required) and params (optional) fields
-var toBatchPayload = function (messages) {
+/**
+ * Should be called to create batch payload object
+ *
+ * @method toBatchPayload
+ * @param {Array} messages, an array of objects with method (required) and params (optional) fields
+ * @returns {Array} batch payload
+ */
+Jsonrpc.prototype.toBatchPayload = function (messages) {
+ var self = this;
return messages.map(function (message) {
- return toPayload(message.method, message.params);
- });
+ return self.toPayload(message.method, message.params);
+ });
};
-module.exports = {
- toPayload: toPayload,
- isValidResponse: isValidResponse,
- toBatchPayload: toBatchPayload
+module.exports = Jsonrpc;
+
+
+},{}],18:[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 .
+*/
+/**
+ * @file method.js
+ * @author Marek Kotewicz
+ * @date 2015
+ */
+
+var RequestManager = require('./requestmanager');
+var utils = require('../utils/utils');
+var errors = require('./errors');
+
+var Method = function (options) {
+ this.name = options.name;
+ this.call = options.call;
+ this.params = options.params || 0;
+ this.inputFormatter = options.inputFormatter;
+ this.outputFormatter = options.outputFormatter;
+};
+
+/**
+ * Should be used to determine name of the jsonrpc method based on arguments
+ *
+ * @method getCall
+ * @param {Array} arguments
+ * @return {String} name of jsonrpc method
+ */
+Method.prototype.getCall = function (args) {
+ return utils.isFunction(this.call) ? this.call(args) : this.call;
+};
+
+/**
+ * Should be used to extract callback from array of arguments. Modifies input param
+ *
+ * @method extractCallback
+ * @param {Array} arguments
+ * @return {Function|Null} callback, if exists
+ */
+Method.prototype.extractCallback = function (args) {
+ if (utils.isFunction(args[args.length - 1])) {
+ return args.pop(); // modify the args array!
+ }
+ return null;
+};
+
+/**
+ * Should be called to check if the number of arguments is correct
+ *
+ * @method validateArgs
+ * @param {Array} arguments
+ * @throws {Error} if it is not
+ */
+Method.prototype.validateArgs = function (args) {
+ if (args.length !== this.params) {
+ throw errors.InvalidNumberOfParams;
+ }
+};
+
+/**
+ * Should be called to format input args of method
+ *
+ * @method formatInput
+ * @param {Array}
+ * @return {Array}
+ */
+Method.prototype.formatInput = function (args) {
+ if (!this.inputFormatter) {
+ return args;
+ }
+
+ return this.inputFormatter.map(function (formatter, index) {
+ return formatter ? formatter(args[index]) : args[index];
+ });
+};
+
+/**
+ * Should be called to format output(result) of method
+ *
+ * @method formatOutput
+ * @param {Object}
+ * @return {Object}
+ */
+Method.prototype.formatOutput = function (result) {
+ return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;
+};
+
+/**
+ * Should attach function to method
+ *
+ * @method attachToObject
+ * @param {Object}
+ * @param {Function}
+ */
+Method.prototype.attachToObject = function (obj) {
+ var func = this.send.bind(this);
+ func.call = this.call; // that's ugly. filter.js uses it
+ var name = this.name.split('.');
+ if (name.length > 1) {
+ obj[name[0]] = obj[name[0]] || {};
+ obj[name[0]][name[1]] = func;
+ } else {
+ obj[name[0]] = func;
+ }
+};
+
+/**
+ * Should create payload from given input args
+ *
+ * @method toPayload
+ * @param {Array} args
+ * @return {Object}
+ */
+Method.prototype.toPayload = function (args) {
+ var call = this.getCall(args);
+ var callback = this.extractCallback(args);
+ var params = this.formatInput(args);
+ this.validateArgs(params);
+
+ return {
+ method: call,
+ params: params,
+ callback: callback
+ };
+};
+
+/**
+ * Should send request to the API
+ *
+ * @method send
+ * @param list of params
+ * @return result
+ */
+Method.prototype.send = function () {
+ var payload = this.toPayload(Array.prototype.slice.call(arguments));
+ if (payload.callback) {
+ var self = this;
+ return RequestManager.getInstance().sendAsync(payload, function (err, result) {
+ payload.callback(null, self.formatOutput(result));
+ });
+ }
+ return this.formatOutput(RequestManager.getInstance().send(payload));
};
+module.exports = Method;
-},{}],15:[function(require,module,exports){
+},{"../utils/utils":6,"./errors":11,"./requestmanager":22}],19:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -2478,16 +2621,23 @@ module.exports = {
*/
var utils = require('../utils/utils');
+var Property = require('./property');
/// @returns an array of objects describing web3.eth api methods
var methods = [
- // { name: 'getBalance', call: 'eth_balanceAt', outputFormatter: formatters.convertToBigNumber},
];
/// @returns an array of objects describing web3.eth api properties
var properties = [
- { name: 'listening', getter: 'net_listening'},
- { name: 'peerCount', getter: 'net_peerCount', outputFormatter: utils.toDecimal },
+ new Property({
+ name: 'listening',
+ getter: 'net_listening'
+ }),
+ new Property({
+ name: 'peerCount',
+ getter: 'net_peerCount',
+ outputFormatter: utils.toDecimal
+ })
];
@@ -2497,7 +2647,113 @@ module.exports = {
};
-},{"../utils/utils":5}],16:[function(require,module,exports){
+},{"../utils/utils":6,"./property":20}],20:[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 .
+*/
+/**
+ * @file property.js
+ * @author Fabian Vogelsteller
+ * @author Marek Kotewicz
+ * @date 2015
+ */
+
+var RequestManager = require('./requestmanager');
+
+var Property = function (options) {
+ this.name = options.name;
+ this.getter = options.getter;
+ this.setter = options.setter;
+ this.outputFormatter = options.outputFormatter;
+ this.inputFormatter = options.inputFormatter;
+};
+
+/**
+ * Should be called to format input args of method
+ *
+ * @method formatInput
+ * @param {Array}
+ * @return {Array}
+ */
+Property.prototype.formatInput = function (arg) {
+ return this.inputFormatter ? this.inputFormatter(arg) : arg;
+};
+
+/**
+ * Should be called to format output(result) of method
+ *
+ * @method formatOutput
+ * @param {Object}
+ * @return {Object}
+ */
+Property.prototype.formatOutput = function (result) {
+ return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;
+};
+
+/**
+ * Should attach function to method
+ *
+ * @method attachToObject
+ * @param {Object}
+ * @param {Function}
+ */
+Property.prototype.attachToObject = function (obj) {
+ var proto = {
+ get: this.get.bind(this),
+ set: this.set.bind(this)
+ };
+
+ var name = this.name.split('.');
+ if (name.length > 1) {
+ obj[name[0]] = obj[name[0]] || {};
+ Object.defineProperty(obj[name[0]], name[1], proto);
+ } else {
+ Object.defineProperty(obj, name[0], proto);
+ }
+};
+
+/**
+ * Should be used to get value of the property
+ *
+ * @method get
+ * @return {Object} value of the property
+ */
+Property.prototype.get = function () {
+ return this.formatOutput(RequestManager.getInstance().send({
+ method: this.getter
+ }));
+};
+
+/**
+ * Should be used to set value of the property
+ *
+ * @method set
+ * @param {Object} new value of the property
+ */
+Property.prototype.set = function (value) {
+ return RequestManager.getInstance().send({
+ method: this.setter,
+ params: [this.formatInput(value)]
+ });
+};
+
+module.exports = Property;
+
+
+},{"./requestmanager":22}],21:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -2532,7 +2788,7 @@ QtSyncProvider.prototype.send = function (payload) {
module.exports = QtSyncProvider;
-},{}],17:[function(require,module,exports){
+},{}],22:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -2549,153 +2805,211 @@ module.exports = QtSyncProvider;
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see .
*/
-/** @file requestmanager.js
- * @authors:
- * Jeffrey Wilcke
- * Marek Kotewicz
- * Marian Oancea
- * Fabian Vogelsteller
- * Gav Wood
+/**
+ * @file requestmanager.js
+ * @author Jeffrey Wilcke
+ * @author Marek Kotewicz
+ * @author Marian Oancea
+ * @author Fabian Vogelsteller
+ * @author Gav Wood
* @date 2014
*/
-var jsonrpc = require('./jsonrpc');
+var Jsonrpc = require('./jsonrpc');
+var utils = require('../utils/utils');
var c = require('../utils/config');
+var errors = require('./errors');
/**
* It's responsible for passing messages to providers
* It's also responsible for polling the ethereum node for incoming messages
* Default poll timeout is 1 second
+ * Singleton
*/
-var requestManager = function() {
- var polls = [];
- var timeout = null;
- var provider;
+var RequestManager = function (provider) {
+ // singleton pattern
+ if (arguments.callee._singletonInstance) {
+ return arguments.callee._singletonInstance;
+ }
+ arguments.callee._singletonInstance = this;
- var send = function (data, callback) {
- /*jshint maxcomplexity: 8 */
+ this.provider = provider;
+ this.polls = [];
+ this.timeout = null;
+ this.poll();
+};
- // FORMAT BASED ON ONE FORMATTER function
- if(typeof data.inputFormatter === 'function') {
- data.params = Array.prototype.map.call(data.params, function(item, index){
- // format everything besides the defaultblock, which is already formated
- return (!data.addDefaultblock || index+1 < data.addDefaultblock) ? data.inputFormatter(item) : item;
- });
+/**
+ * @return {RequestManager} singleton
+ */
+RequestManager.getInstance = function () {
+ var instance = new RequestManager();
+ return instance;
+};
- // FORMAT BASED ON the input FORMATTER ARRAY
- } else if(data.inputFormatter instanceof Array) {
- data.params = Array.prototype.map.call(data.inputFormatter, function(formatter, index){
- // format everything besides the defaultblock, which is already formated
- return (!data.addDefaultblock || index+1 < data.addDefaultblock) ? formatter(data.params[index]) : data.params[index];
- });
- }
+/**
+ * Should be used to synchronously send request
+ *
+ * @method send
+ * @param {Object} data
+ * @return {Object}
+ */
+RequestManager.prototype.send = function (data) {
+ if (!this.provider) {
+ console.error(errors.InvalidProvider);
+ return null;
+ }
+
+ var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);
+ var result = this.provider.send(payload);
+
+ if (!Jsonrpc.getInstance().isValidResponse(result)) {
+ throw errors.InvalidResponse(result);
+ }
+
+ return result.result;
+};
+/**
+ * Should be used to asynchronously send request
+ *
+ * @method sendAsync
+ * @param {Object} data
+ * @param {Function} callback
+ */
+RequestManager.prototype.sendAsync = function (data, callback) {
+ if (!this.provider) {
+ return callback(errors.InvalidProvider);
+ }
- var payload = jsonrpc.toPayload(data.method, data.params);
+ var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);
+ this.provider.sendAsync(payload, function (err, result) {
+ if (err) {
+ return callback(err);
+ }
- if (!provider) {
- console.error('provider is not set');
- return null;
+ if (!Jsonrpc.getInstance().isValidResponse(result)) {
+ return callback(errors.InvalidResponse(result));
}
- // HTTP ASYNC (only when callback is given, and it a HttpProvidor)
- if(typeof callback === 'function' && provider.name === 'HTTP'){
- provider.send(payload, function(result, status){
-
- if (!jsonrpc.isValidResponse(result)) {
- if(typeof result === 'object' && result.error && result.error.message) {
- console.error(result.error.message);
- callback(result.error);
- } else {
- callback(new Error({
- status: status,
- error: result,
- message: 'Bad Request'
- }));
- }
- return null;
- }
-
- // format the output
- callback(null, (typeof data.outputFormatter === 'function') ? data.outputFormatter(result.result) : result.result);
- });
+ callback(null, result.result);
+ });
+};
- // SYNC
- } else {
- var result = provider.send(payload);
+/**
+ * Should be used to set provider of request manager
+ *
+ * @method setProvider
+ * @param {Object}
+ */
+RequestManager.prototype.setProvider = function (p) {
+ this.provider = p;
+};
- if (!jsonrpc.isValidResponse(result)) {
- if(typeof result === 'object' && result.error && result.error.message)
- console.error(result.error.message);
- return null;
- }
+/*jshint maxparams:4 */
- // format the output
- return (typeof data.outputFormatter === 'function') ? data.outputFormatter(result.result) : result.result;
+/**
+ * Should be used to start polling
+ *
+ * @method startPolling
+ * @param {Object} data
+ * @param {Number} pollId
+ * @param {Function} callback
+ * @param {Function} uninstall
+ *
+ * @todo cleanup number of params
+ */
+RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
+ this.polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
+};
+/*jshint maxparams:3 */
+
+/**
+ * Should be used to stop polling for filter with given id
+ *
+ * @method stopPolling
+ * @param {Number} pollId
+ */
+RequestManager.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);
}
-
- };
+ }
+};
- var setProvider = function (p) {
- provider = p;
- };
+/**
+ * Should be called to reset polling mechanism of request manager
+ *
+ * @method reset
+ */
+RequestManager.prototype.reset = function () {
+ this.polls.forEach(function (poll) {
+ poll.uninstall(poll.id);
+ });
+ this.polls = [];
- /*jshint maxparams:4 */
- var startPolling = function (data, pollId, callback, uninstall) {
- polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
- };
- /*jshint maxparams:3 */
+ if (this.timeout) {
+ clearTimeout(this.timeout);
+ this.timeout = null;
+ }
+ this.poll();
+};
- var stopPolling = function (pollId) {
- for (var i = polls.length; i--;) {
- var poll = polls[i];
- if (poll.id === pollId) {
- polls.splice(i, 1);
- }
- }
- };
+/**
+ * Should be called to poll for changes on filter with given id
+ *
+ * @method poll
+ */
+RequestManager.prototype.poll = function () {
+ this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
- var reset = function () {
- polls.forEach(function (poll) {
- poll.uninstall(poll.id);
- });
- polls = [];
+ if (!this.polls.length) {
+ return;
+ }
- if (timeout) {
- clearTimeout(timeout);
- timeout = null;
+ if (!this.provider) {
+ console.error(errors.InvalidProvider);
+ return;
+ }
+
+ var payload = Jsonrpc.getInstance().toBatchPayload(this.polls.map(function (data) {
+ return data.data;
+ }));
+
+ var self = this;
+ this.provider.sendAsync(payload, function (error, results) {
+ // TODO: console log?
+ if (error) {
+ return;
+ }
+
+ if (!utils.isArray(results)) {
+ throw errors.InvalidResponse(results);
}
- poll();
- };
- var poll = function () {
- polls.forEach(function (data) {
- // send async
- send(data.data, function(error, result){
- if (!(result instanceof Array) || result.length === 0) {
- return;
- }
- data.callback(result);
- });
+ results.map(function (result, index) {
+ result.callback = self.polls[index].callback;
+ return result;
+ }).filter(function (result) {
+ var valid = Jsonrpc.getInstance().isValidResponse(result);
+ if (!valid) {
+ result.callback(errors.InvalidResponse(result));
+ }
+ return valid;
+ }).filter(function (result) {
+ return utils.isArray(result.result) && result.result.length > 0;
+ }).forEach(function (result) {
+ result.callback(null, result.result);
});
- timeout = setTimeout(poll, c.ETH_POLLING_TIMEOUT);
- };
-
- poll();
-
- return {
- send: send,
- setProvider: setProvider,
- startPolling: startPolling,
- stopPolling: stopPolling,
- reset: reset
- };
+ });
};
-module.exports = requestManager;
+module.exports = RequestManager;
-},{"../utils/config":4,"./jsonrpc":14}],18:[function(require,module,exports){
+},{"../utils/config":5,"../utils/utils":6,"./errors":11,"./jsonrpc":17}],23:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -2718,28 +3032,54 @@ module.exports = requestManager;
* @date 2015
*/
+var Method = require('./method');
var formatters = require('./formatters');
-/// @returns an array of objects describing web3.shh api methods
-var methods = function () {
- return [
- { name: 'post', call: 'shh_post', inputFormatter: formatters.inputPostFormatter },
- { name: 'newIdentity', call: 'shh_newIdentity' },
- { name: 'hasIdentity', call: 'shh_hasIdentity' },
- { name: 'newGroup', call: 'shh_newGroup' },
- { name: 'addToGroup', call: 'shh_addToGroup' },
-
- // deprecated
- { name: 'haveIdentity', call: 'shh_haveIdentity', newMethod: 'shh.hasIdentity' },
- ];
-};
+var post = new Method({
+ name: 'post',
+ call: 'shh_post',
+ params: 1,
+ inputFormatter: formatters.inputPostFormatter
+});
+
+var newIdentity = new Method({
+ name: 'newIdentity',
+ call: 'shh_newIdentity',
+ params: 0
+});
+
+var hasIdentity = new Method({
+ name: 'hasIdentity',
+ call: 'shh_hasIdentity',
+ params: 1
+});
+
+var newGroup = new Method({
+ name: 'newGroup',
+ call: 'shh_newGroup',
+ params: 0
+});
+
+var addToGroup = new Method({
+ name: 'addToGroup',
+ call: 'shh_addToGroup',
+ params: 0
+});
+
+var methods = [
+ post,
+ newIdentity,
+ hasIdentity,
+ newGroup,
+ addToGroup
+];
module.exports = {
methods: methods
};
-},{"./formatters":12}],19:[function(require,module,exports){
+},{"./formatters":15,"./method":18}],24:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -2783,7 +3123,7 @@ module.exports = {
};
-},{"../utils/config":4,"../web3":6}],20:[function(require,module,exports){
+},{"../utils/config":5,"../web3":8}],25:[function(require,module,exports){
/*
This file is part of ethereum.js.
@@ -2806,25 +3146,77 @@ module.exports = {
* @date 2015
*/
+var Method = require('./method');
+
/// @returns an array of objects describing web3.eth.filter api methods
var eth = function () {
- var newFilter = function (args) {
+ var newFilterCall = function (args) {
return typeof args[0] === 'string' ? 'eth_newBlockFilter' : 'eth_newFilter';
};
+ var newFilter = new Method({
+ name: 'newFilter',
+ call: newFilterCall,
+ params: 1
+ });
+
+ var uninstallFilter = new Method({
+ name: 'uninstallFilter',
+ call: 'eth_uninstallFilter',
+ params: 1
+ });
+
+ var getLogs = new Method({
+ name: 'getLogs',
+ call: 'eth_getFilterLogs',
+ params: 1
+ });
+
+ var poll = new Method({
+ name: 'poll',
+ call: 'eth_getFilterChanges',
+ params: 1
+ });
+
return [
- { name: 'newFilter', call: newFilter },
- { name: 'uninstallFilter', call: 'eth_uninstallFilter' },
- { name: 'getLogs', call: 'eth_getFilterLogs' }
+ newFilter,
+ uninstallFilter,
+ getLogs,
+ poll
];
};
/// @returns an array of objects describing web3.shh.watch api methods
var shh = function () {
+ var newFilter = new Method({
+ name: 'newFilter',
+ call: 'shh_newFilter',
+ params: 1
+ });
+
+ var uninstallFilter = new Method({
+ name: 'uninstallFilter',
+ call: 'shh_uninstallFilter',
+ params: 1
+ });
+
+ var getLogs = new Method({
+ name: 'getLogs',
+ call: 'shh_getMessages',
+ params: 1
+ });
+
+ var poll = new Method({
+ name: 'poll',
+ call: 'shh_getFilterChanges',
+ params: 1
+ });
+
return [
- { name: 'newFilter', call: 'shh_newFilter' },
- { name: 'uninstallFilter', call: 'shh_uninstallFilter' },
- { name: 'getLogs', call: 'shh_getMessages' }
+ newFilter,
+ uninstallFilter,
+ getLogs,
+ poll
];
};
@@ -2834,20 +3226,31 @@ module.exports = {
};
-},{}],21:[function(require,module,exports){
-module.exports={
- "version": "0.1.3"
-}
+},{"./method":18}],26:[function(require,module,exports){
+
+},{}],"bignumber.js":[function(require,module,exports){
+'use strict';
+
+module.exports = BigNumber; // jshint ignore:line
+
+
},{}],"web3":[function(require,module,exports){
-var web3 = require('./lib/web3');
+// dont override global variable
+if (typeof web3 !== 'undefined') {
+ var web3;
+}
+
+web3 = require('./lib/web3');
web3.providers.HttpProvider = require('./lib/web3/httpprovider');
web3.providers.QtSyncProvider = require('./lib/web3/qtsync');
web3.eth.contract = require('./lib/web3/contract');
web3.abi = require('./lib/solidity/abi');
+
+
module.exports = web3;
-},{"./lib/solidity/abi":1,"./lib/web3":6,"./lib/web3/contract":7,"./lib/web3/httpprovider":13,"./lib/web3/qtsync":16}]},{},["web3"])
+},{"./lib/solidity/abi":1,"./lib/web3":8,"./lib/web3/contract":9,"./lib/web3/httpprovider":16,"./lib/web3/qtsync":21}]},{},["web3"])
-//# sourceMappingURL=ethereum.js.map
\ No newline at end of file
+//# sourceMappingURL=web3-light.js.map
\ No newline at end of file
diff --git a/libjsqrc/ethereumjs/dist/web3-light.js.map b/libjsqrc/ethereumjs/dist/web3-light.js.map
new file mode 100644
index 000000000..39e401ff8
--- /dev/null
+++ b/libjsqrc/ethereumjs/dist/web3-light.js.map
@@ -0,0 +1,69 @@
+{
+ "version": 3,
+ "sources": [
+ "node_modules/browserify/node_modules/browser-pack/_prelude.js",
+ "lib/solidity/abi.js",
+ "lib/solidity/formatters.js",
+ "lib/solidity/types.js",
+ "lib/utils/browser-xhr.js",
+ "lib/utils/config.js",
+ "lib/utils/utils.js",
+ "lib/version.json",
+ "lib/web3.js",
+ "lib/web3/contract.js",
+ "lib/web3/db.js",
+ "lib/web3/errors.js",
+ "lib/web3/eth.js",
+ "lib/web3/event.js",
+ "lib/web3/filter.js",
+ "lib/web3/formatters.js",
+ "lib/web3/httpprovider.js",
+ "lib/web3/jsonrpc.js",
+ "lib/web3/method.js",
+ "lib/web3/net.js",
+ "lib/web3/property.js",
+ "lib/web3/qtsync.js",
+ "lib/web3/requestmanager.js",
+ "lib/web3/shh.js",
+ "lib/web3/signature.js",
+ "lib/web3/watches.js",
+ "node_modules/browserify/lib/_empty.js",
+ "lib/utils/browser-bn.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;;ACrPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1eA;AACA;AACA;AACA;;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3NA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrGA;;ACAA;AACA;AACA;AACA;AACA;;ACJA;AACA;AACA;AACA;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.\n*/\n/** @file abi.js\n * @authors:\n * Marek Kotewicz \n * Gav Wood \n * @date 2014\n */\n\nvar utils = require('../utils/utils');\nvar c = require('../utils/config');\nvar types = require('./types');\nvar f = require('./formatters');\n\n/**\n * throw incorrect type error\n *\n * @method throwTypeError\n * @param {String} type\n * @throws incorrect type error\n */\nvar throwTypeError = function (type) {\n throw new Error('parser does not support type: ' + type);\n};\n\n/** This method should be called if we want to check if givent type is an array type\n *\n * @method isArrayType\n * @param {String} type name\n * @returns {Boolean} true if it is, otherwise false\n */\nvar isArrayType = function (type) {\n return type.slice(-2) === '[]';\n};\n\n/**\n * This method should be called to return dynamic type length in hex\n *\n * @method dynamicTypeBytes\n * @param {String} type\n * @param {String|Array} dynamic type\n * @return {String} length of dynamic type in hex or empty string if type is not dynamic\n */\nvar dynamicTypeBytes = function (type, value) {\n // TODO: decide what to do with array of strings\n if (isArrayType(type) || type === 'bytes')\n return f.formatInputInt(value.length);\n return \"\";\n};\n\nvar inputTypes = types.inputTypes();\n\n/**\n * Formats input params to bytes\n *\n * @method formatInput\n * @param {Array} abi inputs of method\n * @param {Array} params that will be formatted to bytes\n * @returns bytes representation of input params\n */\nvar formatInput = function (inputs, params) {\n var bytes = \"\";\n var toAppendConstant = \"\";\n var toAppendArrayContent = \"\";\n\n /// first we iterate in search for dynamic\n inputs.forEach(function (input, index) {\n bytes += dynamicTypeBytes(input.type, params[index]);\n });\n\n inputs.forEach(function (input, i) {\n /*jshint maxcomplexity:5 */\n var typeMatch = false;\n for (var j = 0; j < inputTypes.length && !typeMatch; j++) {\n typeMatch = inputTypes[j].type(inputs[i].type, params[i]);\n }\n if (!typeMatch) {\n throwTypeError(inputs[i].type);\n }\n\n var formatter = inputTypes[j - 1].format;\n\n if (isArrayType(inputs[i].type))\n toAppendArrayContent += params[i].reduce(function (acc, curr) {\n return acc + formatter(curr);\n }, \"\");\n else if (inputs[i].type === 'bytes')\n toAppendArrayContent += formatter(params[i]);\n else\n toAppendConstant += formatter(params[i]);\n });\n\n bytes += toAppendConstant + toAppendArrayContent;\n\n return bytes;\n};\n\n/**\n * This method should be called to predict the length of dynamic type\n *\n * @method dynamicBytesLength\n * @param {String} type\n * @returns {Number} length of dynamic type, 0 or multiplication of ETH_PADDING (32)\n */\nvar dynamicBytesLength = function (type) {\n if (isArrayType(type) || type === 'bytes')\n return c.ETH_PADDING * 2;\n return 0;\n};\n\nvar outputTypes = types.outputTypes();\n\n/** \n * Formats output bytes back to param list\n *\n * @method formatOutput\n * @param {Array} abi outputs of method\n * @param {String} bytes represention of output\n * @returns {Array} output params\n */\nvar formatOutput = function (outs, output) {\n\n output = output.slice(2);\n var result = [];\n var padding = c.ETH_PADDING * 2;\n\n var dynamicPartLength = outs.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 outs.forEach(function (out, i) {\n /*jshint maxcomplexity:6 */\n var typeMatch = false;\n for (var j = 0; j < outputTypes.length && !typeMatch; j++) {\n typeMatch = outputTypes[j].type(outs[i].type);\n }\n\n if (!typeMatch) {\n throwTypeError(outs[i].type);\n }\n\n var formatter = outputTypes[j - 1].format;\n if (isArrayType(outs[i].type)) {\n var size = f.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 (types.prefixedType('bytes')(outs[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/**\n * Should be called to create input parser for contract with given abi\n *\n * @method inputParser\n * @param {Array} contract abi\n * @returns {Object} input parser object for given json abi\n * TODO: refactor creating the parser, do not double logic from contract\n */\nvar inputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n return formatInput(method.inputs, 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/**\n * Should be called to create output parser for contract with given abi\n *\n * @method outputParser\n * @param {Array} contract abi\n * @returns {Object} output parser for given json abi\n */\nvar outputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function (output) {\n return formatOutput(method.outputs, 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\nmodule.exports = {\n inputParser: inputParser,\n outputParser: outputParser,\n formatInput: formatInput,\n formatOutput: formatOutput\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 .\n*/\n/** @file formatters.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar BigNumber = require('bignumber.js');\nvar utils = require('../utils/utils');\nvar c = require('../utils/config');\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 *\n * @method formatInputInt\n * @param {String|Number|BigNumber} value that needs to be formatted\n * @returns {String} right-aligned byte representation of int\n */\nvar formatInputInt = function (value) {\n var padding = c.ETH_PADDING * 2;\n BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);\n return utils.padLeft(utils.toTwosComplement(value).round().toString(16), padding);\n};\n\n/**\n * Formats input value to byte representation of string\n *\n * @method formatInputString\n * @param {String}\n * @returns {String} left-algined byte representation of string\n */\nvar formatInputString = function (value) {\n return utils.fromAscii(value, c.ETH_PADDING).substr(2);\n};\n\n/**\n * Formats input value to byte representation of bool\n *\n * @method formatInputBool\n * @param {Boolean}\n * @returns {String} right-aligned byte representation bool\n */\nvar formatInputBool = function (value) {\n return '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');\n};\n\n/**\n * Formats input value to byte representation of real\n * Values are multiplied by 2^m and encoded as integers\n *\n * @method formatInputReal\n * @param {String|Number|BigNumber}\n * @returns {String} byte representation of real\n */\nvar formatInputReal = function (value) {\n return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128))); \n};\n\n/**\n * Check if input value is negative\n *\n * @method signedIsNegative\n * @param {String} value is hex format\n * @returns {Boolean} true if it is negative, otherwise false\n */\nvar signedIsNegative = function (value) {\n return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';\n};\n\n/**\n * Formats right-aligned output bytes to int\n *\n * @method formatOutputInt\n * @param {String} bytes\n * @returns {BigNumber} right-aligned output bytes formatted to big number\n */\nvar formatOutputInt = function (value) {\n\n value = value || \"0\";\n\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/**\n * Formats right-aligned output bytes to uint\n *\n * @method formatOutputUInt\n * @param {String} bytes\n * @returns {BigNumeber} right-aligned output bytes formatted to uint\n */\nvar formatOutputUInt = function (value) {\n value = value || \"0\";\n return new BigNumber(value, 16);\n};\n\n/**\n * Formats right-aligned output bytes to real\n *\n * @method formatOutputReal\n * @param {String}\n * @returns {BigNumber} input bytes formatted to real\n */\nvar formatOutputReal = function (value) {\n return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/**\n * Formats right-aligned output bytes to ureal\n *\n * @method formatOutputUReal\n * @param {String}\n * @returns {BigNumber} input bytes formatted to ureal\n */\nvar formatOutputUReal = function (value) {\n return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/**\n * Should be used to format output hash\n *\n * @method formatOutputHash\n * @param {String}\n * @returns {String} right-aligned output bytes formatted to hex\n */\nvar formatOutputHash = function (value) {\n return \"0x\" + value;\n};\n\n/**\n * Should be used to format output bool\n *\n * @method formatOutputBool\n * @param {String}\n * @returns {Boolean} right-aligned input bytes formatted to bool\n */\nvar formatOutputBool = function (value) {\n return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;\n};\n\n/**\n * Should be used to format output string\n *\n * @method formatOutputString\n * @param {Sttring} left-aligned hex representation of string\n * @returns {String} ascii string\n */\nvar formatOutputString = function (value) {\n return utils.toAscii(value);\n};\n\n/**\n * Should be used to format output address\n *\n * @method formatOutputAddress\n * @param {String} right-aligned input bytes\n * @returns {String} address\n */\nvar formatOutputAddress = function (value) {\n return \"0x\" + value.slice(value.length - 40, value.length);\n};\n\nmodule.exports = {\n formatInputInt: formatInputInt,\n formatInputString: formatInputString,\n formatInputBool: formatInputBool,\n formatInputReal: formatInputReal,\n formatOutputInt: formatOutputInt,\n formatOutputUInt: formatOutputUInt,\n formatOutputReal: formatOutputReal,\n formatOutputUReal: formatOutputUReal,\n formatOutputHash: formatOutputHash,\n formatOutputBool: formatOutputBool,\n formatOutputString: formatOutputString,\n formatOutputAddress: formatOutputAddress\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 .\n*/\n/** @file types.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar f = require('./formatters');\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\n/// Setups input formatters for solidity types\n/// @returns an array of input formatters \nvar inputTypes = function () {\n \n return [\n { type: prefixedType('uint'), format: f.formatInputInt },\n { type: prefixedType('int'), format: f.formatInputInt },\n { type: prefixedType('bytes'), format: f.formatInputString }, \n { type: prefixedType('real'), format: f.formatInputReal },\n { type: prefixedType('ureal'), format: f.formatInputReal },\n { type: namedType('address'), format: f.formatInputInt },\n { type: namedType('bool'), format: f.formatInputBool }\n ];\n};\n\n/// Setups output formaters for solidity types\n/// @returns an array of output formatters\nvar outputTypes = function () {\n\n return [\n { type: prefixedType('uint'), format: f.formatOutputUInt },\n { type: prefixedType('int'), format: f.formatOutputInt },\n { type: prefixedType('bytes'), format: f.formatOutputString },\n { type: prefixedType('real'), format: f.formatOutputReal },\n { type: prefixedType('ureal'), format: f.formatOutputUReal },\n { type: namedType('address'), format: f.formatOutputAddress },\n { type: namedType('bool'), format: f.formatOutputBool }\n ];\n};\n\nmodule.exports = {\n prefixedType: prefixedType,\n namedType: namedType,\n inputTypes: inputTypes,\n outputTypes: outputTypes\n};\n\n",
+ "'use strict';\n\n// go env doesn't have and need XMLHttpRequest\nif (typeof XMLHttpRequest === 'undefined') {\n exports.XMLHttpRequest = {};\n} else {\n exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line\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 .\n*/\n/** @file config.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\n/**\n * Utils\n * \n * @module utils\n */\n\n/**\n * Utility functions\n * \n * @class [utils] config\n * @constructor\n */\n\n/// required to define ETH_BIGNUMBER_ROUNDING_MODE\nvar BigNumber = require('bignumber.js');\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\nmodule.exports = {\n ETH_PADDING: 32,\n ETH_SIGNATURE_LENGTH: 4,\n ETH_UNITS: ETH_UNITS,\n ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },\n ETH_POLLING_TIMEOUT: 1000,\n ETH_DEFAULTBLOCK: 'latest'\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 .\n*/\n/** @file utils.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\n/**\n * Utils\n * \n * @module utils\n */\n\n/**\n * Utility functions\n * \n * @class [utils] utils\n * @constructor\n */\n\nvar BigNumber = require('bignumber.js');\n\nvar unitMap = {\n 'wei': '1',\n 'kwei': '1000',\n 'ada': '1000',\n 'mwei': '1000000',\n 'babbage': '1000000',\n 'gwei': '1000000000',\n 'shannon': '1000000000',\n 'szabo': '1000000000000',\n 'finney': '1000000000000000',\n 'ether': '1000000000000000000',\n 'kether': '1000000000000000000000',\n 'grand': '1000000000000000000000',\n 'einstein': '1000000000000000000000',\n 'mether': '1000000000000000000000000',\n 'gether': '1000000000000000000000000000',\n 'tether': '1000000000000000000000000000000'\n};\n\n/**\n * Should be called to pad string to expected length\n *\n * @method padLeft\n * @param {String} string to be padded\n * @param {Number} characters that result string should have\n * @param {String} sign, by default 0\n * @returns {String} right aligned string\n */\nvar padLeft = function (string, chars, sign) {\n return new Array(chars - string.length + 1).join(sign ? sign : \"0\") + string;\n};\n\n/** Finds first index of array element matching pattern\n *\n * @method findIndex\n * @param {Array}\n * @param {Function} pattern\n * @returns {Number} index of element\n */\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/** \n * Should be called to get sting from it's hex representation\n *\n * @method toAscii\n * @param {String} string in hex\n * @returns {String} ascii string representation of hex value\n */\nvar 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 }\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/**\n * Shold be called to get hex representation (prefixed by 0x) of ascii string \n *\n * @method fromAscii\n * @param {String} string\n * @returns {String} hex representation of input string\n */\nvar toHexNative = 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/**\n * Shold be called to get hex representation (prefixed by 0x) of ascii string \n *\n * @method fromAscii\n * @param {String} string\n * @param {Number} optional padding\n * @returns {String} hex representation of input string\n */\nvar fromAscii = function(str, pad) {\n pad = pad === undefined ? 0 : pad;\n var hex = toHexNative(str);\n while (hex.length < pad*2)\n hex += \"00\";\n return \"0x\" + hex;\n};\n\n/**\n * Should be called to get display name of contract function\n * \n * @method extractDisplayName\n * @param {String} name of function/event\n * @returns {String} display name for function/event eg. multiply(uint256) -> multiply\n */\nvar extractDisplayName = function (name) {\n var length = name.indexOf('('); \n return length !== -1 ? name.substr(0, length) : name;\n};\n\n/// @returns overloaded part of function/event name\nvar extractTypeName = function (name) {\n /// TODO: make it invulnerable\n var length = name.indexOf('(');\n return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : \"\";\n};\n\n/**\n * Filters all functions from input abi\n *\n * @method filterFunctions\n * @param {Array} abi\n * @returns {Array} abi array with filtered objects of type 'function'\n */\nvar filterFunctions = function (json) {\n return json.filter(function (current) {\n return current.type === 'function'; \n }); \n};\n\n/**\n * Filters all events from input abi\n *\n * @method filterEvents\n * @param {Array} abi\n * @returns {Array} abi array with filtered objects of type 'event'\n */\nvar filterEvents = function (json) {\n return json.filter(function (current) {\n return current.type === 'event';\n });\n};\n\n/**\n * Converts value to it's decimal representation in string\n *\n * @method toDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar toDecimal = function (value) {\n return toBigNumber(value).toNumber();\n};\n\n/**\n * Converts value to it's hex representation\n *\n * @method fromDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar fromDecimal = function (value) {\n var number = toBigNumber(value);\n var result = number.toString(16);\n\n return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;\n};\n\n/**\n * Auto converts any given value into it's hex representation.\n *\n * And even stringifys objects before.\n *\n * @method toHex\n * @param {String|Number|BigNumber|Object}\n * @return {String}\n */\nvar toHex = function (val) {\n /*jshint maxcomplexity:7 */\n\n if (isBoolean(val))\n return fromDecimal(+val);\n\n if (isBigNumber(val))\n return fromDecimal(val);\n\n if (isObject(val))\n return fromAscii(JSON.stringify(val));\n\n // if its a negative number, pass it through fromDecimal\n if (isString(val)) {\n if (val.indexOf('-0x') === 0)\n return fromDecimal(val);\n else if (!isFinite(val))\n return fromAscii(val);\n }\n\n return fromDecimal(val);\n};\n\n/**\n * Returns value of unit in Wei\n *\n * @method getValueOfUnit\n * @param {String} unit the unit to convert to, default ether\n * @returns {BigNumber} value of the unit (in Wei)\n * @throws error if the unit is not correct:w\n */\nvar getValueOfUnit = function (unit) {\n unit = unit ? unit.toLowerCase() : 'ether';\n var unitValue = unitMap[unit];\n if (unitValue === undefined) {\n throw new Error('This unit doesn\\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));\n }\n return new BigNumber(unitValue, 10);\n};\n\n/**\n * Takes a number of wei and converts it to any other ether unit.\n *\n * Possible units are:\n * - kwei/ada\n * - mwei/babbage\n * - gwei/shannon\n * - szabo\n * - finney\n * - ether\n * - kether/grand/einstein\n * - mether\n * - gether\n * - tether\n *\n * @method fromWei\n * @param {Number|String} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert to, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar fromWei = function(number, unit) {\n var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10); \n};\n\n/**\n * Takes a number of a unit and converts it to wei.\n *\n * Possible units are:\n * - kwei/ada\n * - mwei/babbage\n * - gwei/shannon\n * - szabo\n * - finney\n * - ether\n * - kether/grand/einstein\n * - mether\n * - gether\n * - tether\n *\n * @method toWei\n * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert from, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar toWei = function(number, unit) {\n var returnValue = toBigNumber(number).times(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10); \n};\n\n/**\n * Takes an input and transforms it into an bignumber\n *\n * @method toBigNumber\n * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber\n * @return {BigNumber} BigNumber\n*/\nvar toBigNumber = function(number) {\n /*jshint maxcomplexity:5 */\n number = number || 0;\n if (isBigNumber(number))\n return number;\n\n if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {\n return new BigNumber(number.replace('0x',''), 16);\n }\n \n return new BigNumber(number.toString(10), 10);\n};\n\n/**\n * Takes and input transforms it into bignumber and if it is negative value, into two's complement\n *\n * @method toTwosComplement\n * @param {Number|String|BigNumber}\n * @return {BigNumber}\n */\nvar toTwosComplement = function (number) {\n var bigNumber = toBigNumber(number);\n if (bigNumber.lessThan(0)) {\n return new BigNumber(\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\", 16).plus(bigNumber).plus(1);\n }\n return bigNumber;\n};\n\n/**\n * Checks if the given string has proper length\n *\n * @method isAddress\n * @param {String} address the given HEX adress\n * @return {Boolean}\n*/\nvar isAddress = function (address) {\n return /^0x[0-9a-f]{40}$/.test(address);\n};\n\n/**\n * Transforms given string to valid 20 bytes-length addres with 0x prefix\n *\n * @method toAddress\n * @param {String} address\n * @return {String} formatted address\n */\nvar toAddress = function (address) {\n if (isAddress(address)) {\n return address;\n }\n \n if (/^[0-9a-f]{40}$/.test(address)) {\n return '0x' + address;\n }\n\n return '0x' + padLeft(toHex(address).substr(2), 40);\n};\n\n/**\n * Returns true if object is BigNumber, otherwise false\n *\n * @method isBigNumber\n * @param {Object}\n * @return {Boolean} \n */\nvar isBigNumber = function (object) {\n return object instanceof BigNumber ||\n (object && object.constructor && object.constructor.name === 'BigNumber');\n};\n\n/**\n * Returns true if object is string, otherwise false\n * \n * @method isString\n * @param {Object}\n * @return {Boolean}\n */\nvar isString = function (object) {\n return typeof object === 'string' ||\n (object && object.constructor && object.constructor.name === 'String');\n};\n\n/**\n * Returns true if object is function, otherwise false\n *\n * @method isFunction\n * @param {Object}\n * @return {Boolean}\n */\nvar isFunction = function (object) {\n return typeof object === 'function';\n};\n\n/**\n * Returns true if object is Objet, otherwise false\n *\n * @method isObject\n * @param {Object}\n * @return {Boolean}\n */\nvar isObject = function (object) {\n return typeof object === 'object';\n};\n\n/**\n * Returns true if object is boolean, otherwise false\n *\n * @method isBoolean\n * @param {Object}\n * @return {Boolean}\n */\nvar isBoolean = function (object) {\n return typeof object === 'boolean';\n};\n\n/**\n * Returns true if object is array, otherwise false\n *\n * @method isArray\n * @param {Object}\n * @return {Boolean}\n */\nvar isArray = function (object) {\n return object instanceof Array; \n};\n\n/**\n * Returns true if given string is valid json object\n * \n * @method isJson\n * @param {String}\n * @return {Boolean}\n */\nvar isJson = function (str) {\n try {\n return !!JSON.parse(str);\n } catch (e) {\n return false;\n }\n};\n\nmodule.exports = {\n padLeft: padLeft,\n findIndex: findIndex,\n toHex: toHex,\n toDecimal: toDecimal,\n fromDecimal: fromDecimal,\n toAscii: toAscii,\n fromAscii: fromAscii,\n extractDisplayName: extractDisplayName,\n extractTypeName: extractTypeName,\n filterFunctions: filterFunctions,\n filterEvents: filterEvents,\n toWei: toWei,\n fromWei: fromWei,\n toBigNumber: toBigNumber,\n toTwosComplement: toTwosComplement,\n toAddress: toAddress,\n isBigNumber: isBigNumber,\n isAddress: isAddress,\n isFunction: isFunction,\n isString: isString,\n isObject: isObject,\n isBoolean: isBoolean,\n isArray: isArray,\n isJson: isJson\n};\n\n",
+ "module.exports={\n \"version\": \"0.2.5\"\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 .\n*/\n/** @file web3.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * Gav Wood \n * @date 2014\n */\n\nvar version = require('./version.json');\nvar net = require('./web3/net');\nvar eth = require('./web3/eth');\nvar db = require('./web3/db');\nvar shh = require('./web3/shh');\nvar watches = require('./web3/watches');\nvar Filter = require('./web3/filter');\nvar utils = require('./utils/utils');\nvar formatters = require('./web3/formatters');\nvar RequestManager = require('./web3/requestmanager');\nvar c = require('./utils/config');\nvar Method = require('./web3/method');\nvar Property = require('./web3/property');\n\nvar web3Methods = [\n new Method({\n name: 'sha3',\n call: 'web3_sha3',\n params: 1\n })\n];\n\nvar web3Properties = [\n new Property({\n name: 'version.client',\n getter: 'web3_clientVersion'\n }),\n new Property({\n name: 'version.network',\n getter: 'net_version',\n inputFormatter: utils.toDecimal\n }),\n new Property({\n name: 'version.ethereum',\n getter: 'eth_version',\n inputFormatter: utils.toDecimal\n }),\n new Property({\n name: 'version.whisper',\n getter: 'shh_version',\n inputFormatter: utils.toDecimal\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 method.attachToObject(obj);\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 property.attachToObject(obj);\n });\n};\n\n/// setups web3 object, and it's in-browser executed methods\nvar web3 = {};\nweb3.providers = {};\nweb3.version = {};\nweb3.version.api = version.version;\nweb3.eth = {};\n\n/*jshint maxparams:4 */\nweb3.eth.filter = function (fil, eventParams, options, formatter) {\n\n // if its event, treat it differently\n // TODO: simplify and remove\n if (fil._isEvent) {\n return fil(eventParams, options);\n }\n\n // what outputLogFormatter? that's wrong\n //return new Filter(fil, watches.eth(), formatters.outputLogFormatter);\n return new Filter(fil, watches.eth(), formatter || formatters.outputLogFormatter);\n};\n/*jshint maxparams:3 */\n\nweb3.shh = {};\nweb3.shh.filter = function (fil) {\n return new Filter(fil, watches.shh(), formatters.outputPostFormatter);\n};\nweb3.net = {};\nweb3.db = {};\nweb3.setProvider = function (provider) {\n RequestManager.getInstance().setProvider(provider);\n};\nweb3.reset = function () {\n RequestManager.getInstance().reset();\n};\nweb3.toHex = utils.toHex;\nweb3.toAscii = utils.toAscii;\nweb3.fromAscii = utils.fromAscii;\nweb3.toDecimal = utils.toDecimal;\nweb3.fromDecimal = utils.fromDecimal;\nweb3.toBigNumber = utils.toBigNumber;\nweb3.toWei = utils.toWei;\nweb3.fromWei = utils.fromWei;\nweb3.isAddress = utils.isAddress;\n\n// ADD defaultblock\nObject.defineProperty(web3.eth, 'defaultBlock', {\n get: function () {\n return c.ETH_DEFAULTBLOCK;\n },\n set: function (val) {\n c.ETH_DEFAULTBLOCK = val;\n return c.ETH_DEFAULTBLOCK;\n }\n});\n\n\n/// setups all api methods\nsetupMethods(web3, web3Methods);\nsetupProperties(web3, web3Properties);\nsetupMethods(web3.net, net.methods);\nsetupProperties(web3.net, net.properties);\nsetupMethods(web3.eth, eth.methods);\nsetupProperties(web3.eth, eth.properties);\nsetupMethods(web3.db, db.methods);\nsetupMethods(web3.shh, shh.methods);\n\nmodule.exports = web3;\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 .\n*/\n/** @file contract.js\n * @authors:\n * Marek Kotewicz \n * @date 2014\n */\n\nvar web3 = require('../web3'); \nvar abi = require('../solidity/abi');\nvar utils = require('../utils/utils');\nvar eventImpl = require('./event');\nvar signature = require('./signature');\n\nvar addFunctionRelatedPropertiesToContract = function (contract) {\n \n contract.call = function (options) {\n contract._isTransaction = false;\n contract._options = options;\n return contract;\n };\n\n contract.sendTransaction = function (options) {\n contract._isTransaction = true;\n contract._options = options;\n return contract;\n };\n};\n\nvar addFunctionsToContract = function (contract, desc, address) {\n var inputParser = abi.inputParser(desc);\n var outputParser = abi.outputParser(desc);\n\n // create contract functions\n utils.filterFunctions(desc).forEach(function (method) {\n\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function () {\n /*jshint maxcomplexity:7 */\n var params = Array.prototype.slice.call(arguments);\n var sign = signature.functionSignatureFromAscii(method.name);\n var parsed = inputParser[displayName][typeName].apply(null, params);\n\n var options = contract._options || {};\n options.to = address;\n options.data = sign + parsed;\n \n var isTransaction = contract._isTransaction === true || (contract._isTransaction !== false && !method.constant);\n var collapse = options.collapse !== false;\n \n // reset\n contract._options = {};\n contract._isTransaction = null;\n\n if (isTransaction) {\n \n // transactions do not have any output, cause we do not know, when they will be processed\n web3.eth.sendTransaction(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 (contract[displayName] === undefined) {\n contract[displayName] = impl;\n }\n\n contract[displayName][typeName] = impl;\n });\n};\n\nvar addEventRelatedPropertiesToContract = function (contract, desc, address) {\n contract.address = address;\n contract._onWatchEventResult = function (data) {\n var matchingEvent = event.getMatchingEvent(utils.filterEvents(desc));\n var parser = eventImpl.outputParser(matchingEvent);\n return parser(data);\n };\n \n Object.defineProperty(contract, 'topics', {\n get: function() {\n return utils.filterEvents(desc).map(function (e) {\n return signature.eventSignatureFromAscii(e.name);\n });\n }\n });\n\n};\n\nvar addEventsToContract = function (contract, desc, address) {\n // create contract events\n utils.filterEvents(desc).forEach(function (e) {\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n var sign = signature.eventSignatureFromAscii(e.name);\n var event = eventImpl.inputParser(address, sign, e);\n var o = event.apply(null, params);\n var outputFormatter = function (data) {\n var parser = eventImpl.outputParser(e);\n return parser(data);\n };\n return web3.eth.filter(o, undefined, undefined, outputFormatter);\n };\n \n // this property should be used by eth.filter to check if object is an event\n impl._isEvent = true;\n\n var displayName = utils.extractDisplayName(e.name);\n var typeName = utils.extractTypeName(e.name);\n\n if (contract[displayName] === undefined) {\n contract[displayName] = impl;\n }\n\n contract[displayName][typeName] = impl;\n\n });\n};\n\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(abi); // creation of contract prototype\n *\n * var contractInstance = new MyContract('0x0123123121');\n *\n * contractInstance.myMethod('this is test string param for call'); // myMethod call (implicit, default)\n * contractInstance.call().myMethod('this is test string param for call'); // myMethod call (explicit)\n * contractInstance.sendTransaction().myMethod('this is test string param for transact'); // myMethod sendTransaction\n *\n * @param abi - abi json description of the contract, which is being created\n * @returns contract object\n */\nvar contract = function (abi) {\n\n // return prototype\n return Contract.bind(null, abi);\n};\n\nfunction Contract(abi, address) {\n\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 // TODO: we may not want to modify input params, maybe use copy instead?\n abi.forEach(function (method) {\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 result = {};\n addFunctionRelatedPropertiesToContract(result);\n addFunctionsToContract(result, abi, address);\n addEventRelatedPropertiesToContract(result, abi, address);\n addEventsToContract(result, abi, address);\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 .\n*/\n/** @file db.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar Method = require('./method');\n\nvar putString = new Method({\n name: 'putString',\n call: 'db_putString',\n params: 3\n});\n\n\nvar getString = new Method({\n name: 'getString',\n call: 'db_getString',\n params: 2\n});\n\nvar putHex = new Method({\n name: 'putHex',\n call: 'db_putHex',\n params: 3\n});\n\nvar getHex = new Method({\n name: 'getHex',\n call: 'db_getHex',\n params: 2\n});\n\nvar methods = [\n putString, getString, putHex, getHex\n];\n\nmodule.exports = {\n methods: methods\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 .\n*/\n/** \n * @file errors.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\nvar utils = require('../utils/utils');\n\nmodule.exports = {\n InvalidNumberOfParams: new Error('Invalid number of input parameters'),\n InvalidProvider: new Error('Providor not set or invalid'),\n InvalidResponse: function(result){\n var message = 'Invalid JSON RPC response';\n\n if(utils.isObject(result) && result.error && result.error.message) {\n message = result.error.message;\n }\n\n return new Error(message);\n }\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 .\n*/\n/**\n * @file eth.js\n * @author Marek Kotewicz \n * @author Fabian Vogelsteller \n * @date 2015\n */\n\n/**\n * Web3\n * \n * @module web3\n */\n\n/**\n * Eth methods and properties\n *\n * An example method object can look as follows:\n *\n * {\n * name: 'getBlock',\n * call: blockCall,\n * params: 2,\n * outputFormatter: formatters.outputBlockFormatter,\n * inputFormatter: [ // can be a formatter funciton or an array of functions. Where each item in the array will be used for one parameter\n * utils.toHex, // formats paramter 1\n * function(param){ return !!param; } // formats paramter 2\n * ]\n * },\n *\n * @class [web3] eth\n * @constructor\n */\n\n\"use strict\";\n\nvar formatters = require('./formatters');\nvar utils = require('../utils/utils');\nvar Method = require('./method');\nvar Property = require('./property');\n\nvar blockCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? \"eth_getBlockByHash\" : \"eth_getBlockByNumber\";\n};\n\nvar transactionFromBlockCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';\n};\n\nvar uncleCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';\n};\n\nvar getBlockTransactionCountCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';\n};\n\nvar uncleCountCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';\n};\n\n/// @returns an array of objects describing web3.eth api methods\n\nvar getBalance = new Method({\n name: 'getBalance', \n call: 'eth_getBalance', \n params: 2,\n inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter],\n outputFormatter: formatters.outputBigNumberFormatter\n});\n\nvar getStorageAt = new Method({\n name: 'getStorageAt', \n call: 'eth_getStorageAt', \n params: 3,\n inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]\n});\n\nvar getCode = new Method({\n name: 'getCode',\n call: 'eth_getCode',\n params: 2,\n inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter]\n});\n\nvar getBlock = new Method({\n name: 'getBlock', \n call: blockCall,\n params: 2,\n\tinputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],\n outputFormatter: formatters.outputBlockFormatter\n});\n\nvar getUncle = new Method({\n name: 'getUncle',\n call: uncleCall,\n params: 3,\n\tinputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex, function (val) { return !!val; }],\n outputFormatter: formatters.outputBlockFormatter,\n\n});\n\nvar getCompilers = new Method({\n name: 'getCompilers',\n call: 'eth_getCompilers',\n params: 0\n});\n\nvar getBlockTransactionCount = new Method({\n name: 'getBlockTransactionCount',\n call: getBlockTransactionCountCall,\n params: 1,\n inputFormatter: [formatters.inputBlockNumberFormatter],\n outputFormatter: utils.toDecimal\n});\n\nvar getBlockUncleCount = new Method({\n name: 'getBlockUncleCount',\n call: uncleCountCall,\n params: 1,\n inputFormatter: [formatters.inputBlockNumberFormatter],\n outputFormatter: utils.toDecimal\n});\n\nvar getTransaction = new Method({\n name: 'getTransaction',\n call: 'eth_getTransactionByHash',\n params: 1,\n outputFormatter: formatters.outputTransactionFormatter\n});\n\nvar getTransactionFromBlock = new Method({\n name: 'getTransactionFromBlock',\n call: transactionFromBlockCall,\n params: 2,\n inputFormatter: [utils.toHex, utils.toHex],\n outputFormatter: formatters.outputTransactionFormatter\n});\n\nvar getTransactionCount = new Method({\n name: 'getTransactionCount',\n call: 'eth_getTransactionCount',\n params: 2,\n inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],\n outputFormatter: utils.toDecimal\n});\n\nvar sendTransaction = new Method({\n name: 'sendTransaction',\n call: 'eth_sendTransaction',\n params: 1,\n inputFormatter: [formatters.inputTransactionFormatter]\n});\n\nvar call = new Method({\n name: 'call',\n call: 'eth_call',\n params: 2,\n inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter]\n});\n\nvar compileSolidity = new Method({\n name: 'compile.solidity',\n call: 'eth_compileSolidity',\n params: 1\n});\n\nvar compileLLL = new Method({\n name: 'compile.lll',\n call: 'eth_compileLLL',\n params: 1\n});\n\nvar compileSerpent = new Method({\n name: 'compile.serpent',\n call: 'eth_compileSerpent',\n params: 1\n});\n\nvar flush = new Method({\n name: 'flush',\n call: 'eth_flush',\n params: 0\n});\n\nvar methods = [\n getBalance,\n getStorageAt,\n getCode,\n getBlock,\n getUncle,\n getCompilers,\n getBlockTransactionCount,\n getBlockUncleCount,\n getTransaction,\n getTransactionFromBlock,\n getTransactionCount,\n call,\n sendTransaction,\n compileSolidity,\n compileLLL,\n compileSerpent,\n flush\n];\n\n/// @returns an array of objects describing web3.eth api properties\n\n\n\nvar properties = [\n new Property({\n name: 'coinbase',\n getter: 'eth_coinbase'\n }),\n new Property({\n name: 'mining',\n getter: 'eth_mining'\n }),\n new Property({\n name: 'gasPrice',\n getter: 'eth_gasPrice',\n outputFormatter: formatters.inputNumberFormatter\n }),\n new Property({\n name: 'accounts',\n getter: 'eth_accounts'\n }),\n new Property({\n name: 'blockNumber',\n getter: 'eth_blockNumber',\n outputFormatter: utils.toDecimal\n })\n];\n\nmodule.exports = {\n methods: methods,\n properties: properties\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 .\n*/\n/** @file event.js\n * @authors:\n * Marek Kotewicz \n * @date 2014\n */\n\nvar abi = require('../solidity/abi');\nvar utils = require('../utils/utils');\nvar signature = require('./signature');\n\n/// filter inputs array && returns only indexed (or not) inputs\n/// @param inputs array\n/// @param bool if result should be an array of indexed params on not\n/// @returns array of (not?) indexed params\nvar filterInputs = function (inputs, indexed) {\n return inputs.filter(function (current) {\n return current.indexed === indexed;\n });\n};\n\nvar inputWithName = function (inputs, name) {\n var index = utils.findIndex(inputs, function (input) {\n return input.name === name;\n });\n \n if (index === -1) {\n console.error('indexed param with name ' + name + ' not found');\n return undefined;\n }\n return inputs[index];\n};\n\nvar indexedParamsToTopics = function (event, indexed) {\n // sort keys?\n return Object.keys(indexed).map(function (key) {\n var inputs = [inputWithName(filterInputs(event.inputs, true), key)];\n\n var value = indexed[key];\n if (value instanceof Array) {\n return value.map(function (v) {\n return abi.formatInput(inputs, [v]);\n }); \n }\n return '0x' + abi.formatInput(inputs, [value]);\n });\n};\n\nvar inputParser = function (address, sign, event) {\n \n // valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.filter'\n return function (indexed, options) {\n var o = options || {};\n o.address = address;\n o.topics = [];\n o.topics.push(sign);\n if (indexed) {\n o.topics = o.topics.concat(indexedParamsToTopics(event, indexed));\n }\n return o;\n };\n};\n\nvar getArgumentsObject = function (inputs, indexed, notIndexed) {\n var indexedCopy = indexed.slice();\n var notIndexedCopy = notIndexed.slice();\n return inputs.reduce(function (acc, current) {\n var value;\n if (current.indexed)\n value = indexedCopy.splice(0, 1)[0];\n else\n value = notIndexedCopy.splice(0, 1)[0];\n\n acc[current.name] = value;\n return acc;\n }, {}); \n};\n \nvar outputParser = function (event) {\n \n return function (output) {\n var result = {\n event: utils.extractDisplayName(event.name),\n number: output.number,\n hash: output.hash,\n args: {}\n };\n\n if (!output.topics) {\n return result;\n }\n output.data = output.data || '';\n \n var indexedOutputs = filterInputs(event.inputs, true);\n var indexedData = \"0x\" + output.topics.slice(1, output.topics.length).map(function (topics) { return topics.slice(2); }).join(\"\");\n var indexedRes = abi.formatOutput(indexedOutputs, indexedData);\n\n var notIndexedOutputs = filterInputs(event.inputs, false);\n var notIndexedRes = abi.formatOutput(notIndexedOutputs, output.data);\n\n result.args = getArgumentsObject(event.inputs, indexedRes, notIndexedRes);\n\n return result;\n };\n};\n\nvar getMatchingEvent = function (events, payload) {\n for (var i = 0; i < events.length; i++) {\n var sign = signature.eventSignatureFromAscii(events[i].name); \n if (sign === payload.topics[0]) {\n return events[i];\n }\n }\n return undefined;\n};\n\n\nmodule.exports = {\n inputParser: inputParser,\n outputParser: outputParser,\n getMatchingEvent: getMatchingEvent\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 .\n*/\n/** @file filter.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * Gav Wood \n * @date 2014\n */\n\nvar RequestManager = require('./requestmanager');\nvar formatters = require('./formatters');\nvar utils = require('../utils/utils');\n\n/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones\n/// @param should be string or object\n/// @returns options string or object\nvar getOptions = function (options) {\n\n if (utils.isString(options)) {\n return options;\n } \n\n options = options || {};\n\n // make sure topics, get converted to hex\n options.topics = options.topics || [];\n options.topics = options.topics.map(function(topic){\n return utils.toHex(topic);\n });\n\n // lazy load\n return {\n topics: options.topics,\n to: options.to,\n address: options.address,\n fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),\n toBlock: formatters.inputBlockNumberFormatter(options.toBlock) \n }; \n};\n\nvar Filter = function (options, methods, formatter) {\n var implementation = {};\n methods.forEach(function (method) {\n method.attachToObject(implementation);\n });\n this.options = getOptions(options);\n this.implementation = implementation;\n this.callbacks = [];\n this.formatter = formatter;\n this.filterId = this.implementation.newFilter(this.options);\n};\n\nFilter.prototype.watch = function (callback) {\n this.callbacks.push(callback);\n var self = this;\n\n var onMessage = function (error, messages) {\n if (error) {\n return self.callbacks.forEach(function (callback) {\n callback(error);\n });\n }\n\n messages.forEach(function (message) {\n message = self.formatter ? self.formatter(message) : message;\n self.callbacks.forEach(function (callback) {\n callback(null, message);\n });\n });\n };\n\n RequestManager.getInstance().startPolling({\n method: this.implementation.poll.call,\n params: [this.filterId],\n }, this.filterId, onMessage, this.stopWatching.bind(this));\n};\n\nFilter.prototype.stopWatching = function () {\n RequestManager.getInstance().stopPolling(this.filterId);\n this.implementation.uninstallFilter(this.filterId);\n this.callbacks = [];\n};\n\nFilter.prototype.get = function () {\n var logs = this.implementation.getLogs(this.filterId);\n var self = this;\n return logs.map(function (log) {\n return self.formatter ? self.formatter(log) : log;\n });\n};\n\nmodule.exports = Filter;\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 .\n*/\n/** \n * @file formatters.js\n * @author Marek Kotewicz \n * @author Fabian Vogelsteller \n * @date 2015\n */\n\nvar utils = require('../utils/utils');\nvar config = require('../utils/config');\n\n/**\n * Should the format output to a big number\n *\n * @method outputBigNumberFormatter\n * @param {String|Number|BigNumber}\n * @returns {BigNumber} object\n */\nvar outputBigNumberFormatter = function (number) {\n return utils.toBigNumber(number);\n};\n\nvar isPredefinedBlockNumber = function (blockNumber) {\n return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';\n};\n\nvar inputDefaultBlockNumberFormatter = function (blockNumber) {\n if (blockNumber === undefined) {\n return config.ETH_DEFAULTBLOCK;\n }\n return inputBlockNumberFormatter(blockNumber);\n};\n\nvar inputBlockNumberFormatter = function (blockNumber) {\n if (blockNumber === undefined) {\n return undefined;\n } else if (isPredefinedBlockNumber(blockNumber)) {\n return blockNumber;\n }\n return utils.toHex(blockNumber);\n};\n\n/**\n * Formats the input of a transaction and converts all values to HEX\n *\n * @method inputTransactionFormatter\n * @param {Object} transaction options\n * @returns object\n*/\nvar inputTransactionFormatter = function (options){\n\n // make code -> data\n if (options.code) {\n options.data = options.code;\n delete options.code;\n }\n\n ['gasPrice', 'gas', 'value'].filter(function (key) {\n return options[key] !== undefined;\n }).forEach(function(key){\n options[key] = utils.fromDecimal(options[key]);\n });\n\n return options; \n};\n\n/**\n * Formats the output of a transaction to its proper values\n * \n * @method outputTransactionFormatter\n * @param {Object} transaction\n * @returns {Object} transaction\n*/\nvar outputTransactionFormatter = function (tx){\n tx.blockNumber = utils.toDecimal(tx.blockNumber);\n tx.transactionIndex = utils.toDecimal(tx.transactionIndex);\n tx.gas = utils.toDecimal(tx.gas);\n tx.gasPrice = utils.toBigNumber(tx.gasPrice);\n tx.value = utils.toBigNumber(tx.value);\n return tx;\n};\n\n/**\n * Formats the output of a block to its proper values\n *\n * @method outputBlockFormatter\n * @param {Object} block object \n * @returns {Object} block object\n*/\nvar outputBlockFormatter = function(block) {\n\n // transform to number\n block.gasLimit = utils.toDecimal(block.gasLimit);\n block.gasUsed = utils.toDecimal(block.gasUsed);\n block.size = utils.toDecimal(block.size);\n block.timestamp = utils.toDecimal(block.timestamp);\n block.number = utils.toDecimal(block.number);\n\n block.minGasPrice = utils.toBigNumber(block.minGasPrice);\n block.difficulty = utils.toBigNumber(block.difficulty);\n block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);\n\n if (utils.isArray(block.transactions)) {\n block.transactions.forEach(function(item){\n if(!utils.isString(item))\n return outputTransactionFormatter(item);\n });\n }\n\n return block;\n};\n\n/**\n * Formats the output of a log\n * \n * @method outputLogFormatter\n * @param {Object} log object\n * @returns {Object} log\n*/\nvar outputLogFormatter = function(log) {\n if (log === null) { // 'pending' && 'latest' filters are nulls\n return null;\n }\n\n log.blockNumber = utils.toDecimal(log.blockNumber);\n log.transactionIndex = utils.toDecimal(log.transactionIndex);\n log.logIndex = utils.toDecimal(log.logIndex);\n\n return log;\n};\n\n/**\n * Formats the input of a whisper post and converts all values to HEX\n *\n * @method inputPostFormatter\n * @param {Object} transaction object\n * @returns {Object}\n*/\nvar inputPostFormatter = function(post) {\n\n post.payload = utils.toHex(post.payload);\n post.ttl = utils.fromDecimal(post.ttl);\n post.priority = utils.fromDecimal(post.priority);\n\n if(!utils.isArray(post.topics)) {\n post.topics = [post.topics];\n }\n\n // format the following options\n post.topics = post.topics.map(function(topic){\n return utils.fromAscii(topic);\n });\n\n return post; \n};\n\n/**\n * Formats the output of a received post message\n *\n * @method outputPostFormatter\n * @param {Object}\n * @returns {Object}\n */\nvar outputPostFormatter = function(post){\n\n post.expiry = utils.toDecimal(post.expiry);\n post.sent = utils.toDecimal(post.sent);\n post.ttl = utils.toDecimal(post.ttl);\n post.workProved = utils.toDecimal(post.workProved);\n post.payloadRaw = post.payload;\n post.payload = utils.toAscii(post.payload);\n\n if (utils.isJson(post.payload)) {\n post.payload = JSON.parse(post.payload);\n }\n\n // format the following options\n post.topics = post.topics.map(function(topic){\n return utils.toAscii(topic);\n });\n\n return post;\n};\n\nmodule.exports = {\n inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,\n inputBlockNumberFormatter: inputBlockNumberFormatter,\n inputTransactionFormatter: inputTransactionFormatter,\n inputPostFormatter: inputPostFormatter,\n outputBigNumberFormatter: outputBigNumberFormatter,\n outputTransactionFormatter: outputTransactionFormatter,\n outputBlockFormatter: outputBlockFormatter,\n outputLogFormatter: outputLogFormatter,\n outputPostFormatter: outputPostFormatter\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 .\n*/\n/** @file httpprovider.js\n * @authors:\n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * @date 2014\n */\n\n\"use strict\";\n\nvar XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line\n\nvar HttpProvider = function (host) {\n this.host = host || 'http://localhost:8080';\n};\n\nHttpProvider.prototype.send = function (payload) {\n var request = new XMLHttpRequest();\n\n request.open('POST', this.host, false);\n request.send(JSON.stringify(payload));\n\n // check request.status\n // TODO: throw an error here! it cannot silently fail!!!\n //if (request.status !== 200) {\n //return;\n //}\n return JSON.parse(request.responseText);\n};\n\nHttpProvider.prototype.sendAsync = function (payload, callback) {\n var request = new XMLHttpRequest();\n request.onreadystatechange = function() {\n if (request.readyState === 4) {\n // TODO: handle the error properly here!!!\n callback(null, JSON.parse(request.responseText));\n }\n };\n\n request.open('POST', this.host, true);\n request.send(JSON.stringify(payload));\n};\n\nmodule.exports = HttpProvider;\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 .\n*/\n/** @file jsonrpc.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar Jsonrpc = function () {\n // singleton pattern\n if (arguments.callee._singletonInstance) {\n return arguments.callee._singletonInstance;\n }\n arguments.callee._singletonInstance = this;\n\n this.messageId = 1;\n};\n\n/**\n * @return {Jsonrpc} singleton\n */\nJsonrpc.getInstance = function () {\n var instance = new Jsonrpc();\n return instance;\n};\n\n/**\n * Should be called to valid json create payload object\n *\n * @method toPayload\n * @param {Function} method of jsonrpc call, required\n * @param {Array} params, an array of method params, optional\n * @returns {Object} valid jsonrpc payload object\n */\nJsonrpc.prototype.toPayload = function (method, params) {\n if (!method)\n console.error('jsonrpc method should be specified!');\n\n return {\n jsonrpc: '2.0',\n method: method,\n params: params || [],\n id: this.messageId++\n };\n};\n\n/**\n * Should be called to check if jsonrpc response is valid\n *\n * @method isValidResponse\n * @param {Object}\n * @returns {Boolean} true if response is valid, otherwise false\n */\nJsonrpc.prototype.isValidResponse = function (response) {\n return !!response &&\n !response.error &&\n response.jsonrpc === '2.0' &&\n typeof response.id === 'number' &&\n response.result !== undefined; // only undefined is not valid json object\n};\n\n/**\n * Should be called to create batch payload object\n *\n * @method toBatchPayload\n * @param {Array} messages, an array of objects with method (required) and params (optional) fields\n * @returns {Array} batch payload\n */\nJsonrpc.prototype.toBatchPayload = function (messages) {\n var self = this;\n return messages.map(function (message) {\n return self.toPayload(message.method, message.params);\n });\n};\n\nmodule.exports = Jsonrpc;\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 .\n*/\n/**\n * @file method.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\nvar RequestManager = require('./requestmanager');\nvar utils = require('../utils/utils');\nvar errors = require('./errors');\n\nvar Method = function (options) {\n this.name = options.name;\n this.call = options.call;\n this.params = options.params || 0;\n this.inputFormatter = options.inputFormatter;\n this.outputFormatter = options.outputFormatter;\n};\n\n/**\n * Should be used to determine name of the jsonrpc method based on arguments\n *\n * @method getCall\n * @param {Array} arguments\n * @return {String} name of jsonrpc method\n */\nMethod.prototype.getCall = function (args) {\n return utils.isFunction(this.call) ? this.call(args) : this.call;\n};\n\n/**\n * Should be used to extract callback from array of arguments. Modifies input param\n *\n * @method extractCallback\n * @param {Array} arguments\n * @return {Function|Null} callback, if exists\n */\nMethod.prototype.extractCallback = function (args) {\n if (utils.isFunction(args[args.length - 1])) {\n return args.pop(); // modify the args array!\n }\n return null;\n};\n\n/**\n * Should be called to check if the number of arguments is correct\n * \n * @method validateArgs\n * @param {Array} arguments\n * @throws {Error} if it is not\n */\nMethod.prototype.validateArgs = function (args) {\n if (args.length !== this.params) {\n throw errors.InvalidNumberOfParams;\n }\n};\n\n/**\n * Should be called to format input args of method\n * \n * @method formatInput\n * @param {Array}\n * @return {Array}\n */\nMethod.prototype.formatInput = function (args) {\n if (!this.inputFormatter) {\n return args;\n }\n\n return this.inputFormatter.map(function (formatter, index) {\n return formatter ? formatter(args[index]) : args[index];\n });\n};\n\n/**\n * Should be called to format output(result) of method\n *\n * @method formatOutput\n * @param {Object}\n * @return {Object}\n */\nMethod.prototype.formatOutput = function (result) {\n return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;\n};\n\n/**\n * Should attach function to method\n * \n * @method attachToObject\n * @param {Object}\n * @param {Function}\n */\nMethod.prototype.attachToObject = function (obj) {\n var func = this.send.bind(this);\n func.call = this.call; // that's ugly. filter.js uses it\n var name = this.name.split('.');\n if (name.length > 1) {\n obj[name[0]] = obj[name[0]] || {};\n obj[name[0]][name[1]] = func;\n } else {\n obj[name[0]] = func; \n }\n};\n\n/**\n * Should create payload from given input args\n *\n * @method toPayload\n * @param {Array} args\n * @return {Object}\n */\nMethod.prototype.toPayload = function (args) {\n var call = this.getCall(args);\n var callback = this.extractCallback(args);\n var params = this.formatInput(args);\n this.validateArgs(params);\n\n return {\n method: call,\n params: params,\n callback: callback\n };\n};\n\n/**\n * Should send request to the API\n *\n * @method send\n * @param list of params\n * @return result\n */\nMethod.prototype.send = function () {\n var payload = this.toPayload(Array.prototype.slice.call(arguments));\n if (payload.callback) {\n var self = this;\n return RequestManager.getInstance().sendAsync(payload, function (err, result) {\n payload.callback(null, self.formatOutput(result));\n });\n }\n return this.formatOutput(RequestManager.getInstance().send(payload));\n};\n\nmodule.exports = Method;\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 .\n*/\n/** @file eth.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar utils = require('../utils/utils');\nvar Property = require('./property');\n\n/// @returns an array of objects describing web3.eth api methods\nvar methods = [\n];\n\n/// @returns an array of objects describing web3.eth api properties\nvar properties = [\n new Property({\n name: 'listening',\n getter: 'net_listening'\n }),\n new Property({\n name: 'peerCount',\n getter: 'net_peerCount',\n outputFormatter: utils.toDecimal\n })\n];\n\n\nmodule.exports = {\n methods: methods,\n properties: properties\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 .\n*/\n/**\n * @file property.js\n * @author Fabian Vogelsteller \n * @author Marek Kotewicz \n * @date 2015\n */\n\nvar RequestManager = require('./requestmanager');\n\nvar Property = function (options) {\n this.name = options.name;\n this.getter = options.getter;\n this.setter = options.setter;\n this.outputFormatter = options.outputFormatter;\n this.inputFormatter = options.inputFormatter;\n};\n\n/**\n * Should be called to format input args of method\n * \n * @method formatInput\n * @param {Array}\n * @return {Array}\n */\nProperty.prototype.formatInput = function (arg) {\n return this.inputFormatter ? this.inputFormatter(arg) : arg;\n};\n\n/**\n * Should be called to format output(result) of method\n *\n * @method formatOutput\n * @param {Object}\n * @return {Object}\n */\nProperty.prototype.formatOutput = function (result) {\n return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;\n};\n\n/**\n * Should attach function to method\n * \n * @method attachToObject\n * @param {Object}\n * @param {Function}\n */\nProperty.prototype.attachToObject = function (obj) {\n var proto = {\n get: this.get.bind(this),\n set: this.set.bind(this)\n };\n\n var name = this.name.split('.');\n if (name.length > 1) {\n obj[name[0]] = obj[name[0]] || {};\n Object.defineProperty(obj[name[0]], name[1], proto); \n } else {\n Object.defineProperty(obj, name[0], proto);\n }\n};\n\n/**\n * Should be used to get value of the property\n *\n * @method get\n * @return {Object} value of the property\n */\nProperty.prototype.get = function () {\n return this.formatOutput(RequestManager.getInstance().send({\n method: this.getter\n }));\n};\n\n/**\n * Should be used to set value of the property\n *\n * @method set\n * @param {Object} new value of the property\n */\nProperty.prototype.set = function (value) {\n return RequestManager.getInstance().send({\n method: this.setter,\n params: [this.formatInput(value)]\n });\n};\n\nmodule.exports = Property;\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 .\n*/\n/** @file qtsync.js\n * @authors:\n * Marek Kotewicz \n * Marian Oancea \n * @date 2014\n */\n\nvar QtSyncProvider = function () {\n};\n\nQtSyncProvider.prototype.send = function (payload) {\n var result = navigator.qt.callMethod(JSON.stringify(payload));\n return JSON.parse(result);\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 .\n*/\n/** \n * @file requestmanager.js\n * @author Jeffrey Wilcke \n * @author Marek Kotewicz \n * @author Marian Oancea \n * @author Fabian Vogelsteller \n * @author Gav Wood \n * @date 2014\n */\n\nvar Jsonrpc = require('./jsonrpc');\nvar utils = require('../utils/utils');\nvar c = require('../utils/config');\nvar errors = require('./errors');\n\n/**\n * It's responsible for passing messages to providers\n * It's also responsible for polling the ethereum node for incoming messages\n * Default poll timeout is 1 second\n * Singleton\n */\nvar RequestManager = function (provider) {\n // singleton pattern\n if (arguments.callee._singletonInstance) {\n return arguments.callee._singletonInstance;\n }\n arguments.callee._singletonInstance = this;\n\n this.provider = provider;\n this.polls = [];\n this.timeout = null;\n this.poll();\n};\n\n/**\n * @return {RequestManager} singleton\n */\nRequestManager.getInstance = function () {\n var instance = new RequestManager();\n return instance;\n};\n\n/**\n * Should be used to synchronously send request\n *\n * @method send\n * @param {Object} data\n * @return {Object}\n */\nRequestManager.prototype.send = function (data) {\n if (!this.provider) {\n console.error(errors.InvalidProvider);\n return null;\n }\n\n var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);\n var result = this.provider.send(payload);\n\n if (!Jsonrpc.getInstance().isValidResponse(result)) {\n throw errors.InvalidResponse(result);\n }\n\n return result.result;\n};\n\n/**\n * Should be used to asynchronously send request\n *\n * @method sendAsync\n * @param {Object} data\n * @param {Function} callback\n */\nRequestManager.prototype.sendAsync = function (data, callback) {\n if (!this.provider) {\n return callback(errors.InvalidProvider);\n }\n\n var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);\n this.provider.sendAsync(payload, function (err, result) {\n if (err) {\n return callback(err);\n }\n \n if (!Jsonrpc.getInstance().isValidResponse(result)) {\n return callback(errors.InvalidResponse(result));\n }\n\n callback(null, result.result);\n });\n};\n\n/**\n * Should be used to set provider of request manager\n *\n * @method setProvider\n * @param {Object}\n */\nRequestManager.prototype.setProvider = function (p) {\n this.provider = p;\n};\n\n/*jshint maxparams:4 */\n\n/**\n * Should be used to start polling\n *\n * @method startPolling\n * @param {Object} data\n * @param {Number} pollId\n * @param {Function} callback\n * @param {Function} uninstall\n *\n * @todo cleanup number of params\n */\nRequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {\n this.polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});\n};\n/*jshint maxparams:3 */\n\n/**\n * Should be used to stop polling for filter with given id\n *\n * @method stopPolling\n * @param {Number} pollId\n */\nRequestManager.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\n/**\n * Should be called to reset polling mechanism of request manager\n *\n * @method reset\n */\nRequestManager.prototype.reset = function () {\n this.polls.forEach(function (poll) {\n poll.uninstall(poll.id); \n });\n this.polls = [];\n\n if (this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = null;\n }\n this.poll();\n};\n\n/**\n * Should be called to poll for changes on filter with given id\n *\n * @method poll\n */\nRequestManager.prototype.poll = function () {\n this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);\n\n if (!this.polls.length) {\n return;\n }\n\n if (!this.provider) {\n console.error(errors.InvalidProvider);\n return;\n }\n\n var payload = Jsonrpc.getInstance().toBatchPayload(this.polls.map(function (data) {\n return data.data;\n }));\n\n var self = this;\n this.provider.sendAsync(payload, function (error, results) {\n // TODO: console log?\n if (error) {\n return;\n }\n \n if (!utils.isArray(results)) {\n throw errors.InvalidResponse(results);\n }\n\n results.map(function (result, index) {\n result.callback = self.polls[index].callback;\n return result;\n }).filter(function (result) {\n var valid = Jsonrpc.getInstance().isValidResponse(result);\n if (!valid) {\n result.callback(errors.InvalidResponse(result));\n }\n return valid;\n }).filter(function (result) {\n return utils.isArray(result.result) && result.result.length > 0;\n }).forEach(function (result) {\n result.callback(null, result.result);\n });\n });\n};\n\nmodule.exports = RequestManager;\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 .\n*/\n/** @file shh.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar Method = require('./method');\nvar formatters = require('./formatters');\n\nvar post = new Method({\n name: 'post', \n call: 'shh_post', \n params: 1,\n inputFormatter: formatters.inputPostFormatter\n});\n\nvar newIdentity = new Method({\n name: 'newIdentity',\n call: 'shh_newIdentity',\n params: 0\n});\n\nvar hasIdentity = new Method({\n name: 'hasIdentity',\n call: 'shh_hasIdentity',\n params: 1\n});\n\nvar newGroup = new Method({\n name: 'newGroup',\n call: 'shh_newGroup',\n params: 0\n});\n\nvar addToGroup = new Method({\n name: 'addToGroup',\n call: 'shh_addToGroup',\n params: 0\n});\n\nvar methods = [\n post,\n newIdentity,\n hasIdentity,\n newGroup,\n addToGroup\n];\n\nmodule.exports = {\n methods: methods\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 .\n*/\n/** @file signature.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar web3 = require('../web3'); \nvar c = require('../utils/config');\n\n/// @param function name for which we want to get signature\n/// @returns signature of function with given name\nvar functionSignatureFromAscii = function (name) {\n return web3.sha3(web3.fromAscii(name)).slice(0, 2 + c.ETH_SIGNATURE_LENGTH * 2);\n};\n\n/// @param event name for which we want to get signature\n/// @returns signature of event with given name\nvar eventSignatureFromAscii = function (name) {\n return web3.sha3(web3.fromAscii(name));\n};\n\nmodule.exports = {\n functionSignatureFromAscii: functionSignatureFromAscii,\n eventSignatureFromAscii: eventSignatureFromAscii\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 .\n*/\n/** @file watches.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar Method = require('./method');\n\n/// @returns an array of objects describing web3.eth.filter api methods\nvar eth = function () {\n var newFilterCall = function (args) {\n return typeof args[0] === 'string' ? 'eth_newBlockFilter' : 'eth_newFilter';\n };\n\n var newFilter = new Method({\n name: 'newFilter',\n call: newFilterCall,\n params: 1\n });\n\n var uninstallFilter = new Method({\n name: 'uninstallFilter',\n call: 'eth_uninstallFilter',\n params: 1\n });\n\n var getLogs = new Method({\n name: 'getLogs',\n call: 'eth_getFilterLogs',\n params: 1\n });\n\n var poll = new Method({\n name: 'poll',\n call: 'eth_getFilterChanges',\n params: 1\n });\n\n return [\n newFilter,\n uninstallFilter,\n getLogs,\n poll\n ];\n};\n\n/// @returns an array of objects describing web3.shh.watch api methods\nvar shh = function () {\n var newFilter = new Method({\n name: 'newFilter',\n call: 'shh_newFilter',\n params: 1\n });\n\n var uninstallFilter = new Method({\n name: 'uninstallFilter',\n call: 'shh_uninstallFilter',\n params: 1\n });\n\n var getLogs = new Method({\n name: 'getLogs',\n call: 'shh_getMessages',\n params: 1\n });\n\n var poll = new Method({\n name: 'poll',\n call: 'shh_getFilterChanges',\n params: 1\n });\n\n return [\n newFilter,\n uninstallFilter,\n getLogs,\n poll\n ];\n};\n\nmodule.exports = {\n eth: eth,\n shh: shh\n};\n\n",
+ null,
+ "'use strict';\n\nmodule.exports = BigNumber; // jshint ignore:line\n\n",
+ "// dont override global variable\nif (typeof web3 !== 'undefined') {\n var web3;\n}\n\nweb3 = require('./lib/web3');\nweb3.providers.HttpProvider = require('./lib/web3/httpprovider');\nweb3.providers.QtSyncProvider = require('./lib/web3/qtsync');\nweb3.eth.contract = require('./lib/web3/contract');\nweb3.abi = require('./lib/solidity/abi');\n\n\n\nmodule.exports = web3;\n"
+ ]
+}
\ No newline at end of file
diff --git a/libjsqrc/ethereumjs/dist/web3-light.min.js b/libjsqrc/ethereumjs/dist/web3-light.min.js
new file mode 100644
index 000000000..e7c5c9f1c
--- /dev/null
+++ b/libjsqrc/ethereumjs/dist/web3-light.min.js
@@ -0,0 +1 @@
+require=function t(e,n,r){function o(a,u){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return o(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;av;v++)g.push(h(e.slice(0,s))),e=e.slice(s);n.push(g)}else o.prefixedType("bytes")(t[c].type)?(l=l.slice(s),n.push(h(e.slice(0,s))),e=e.slice(s)):(n.push(h(e.slice(0,s))),e=e.slice(s))}),n},h=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),o=n.extractTypeName(t.name),i=function(){var e=Array.prototype.slice.call(arguments);return l(t.inputs,e)};void 0===e[r]&&(e[r]=i),e[r][o]=i}),e},d=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),o=n.extractTypeName(t.name),i=function(e){return m(t.outputs,e)};void 0===e[r]&&(e[r]=i),e[r][o]=i}),e};e.exports={inputParser:h,outputParser:d,formatInput:l,formatOutput:m}},{"../utils/config":5,"../utils/utils":6,"./formatters":2,"./types":3}],2:[function(t,e){var n=t("bignumber.js"),r=t("../utils/utils"),o=t("../utils/config"),i=function(t){var e=2*o.ETH_PADDING;return n.config(o.ETH_BIGNUMBER_ROUNDING_MODE),r.padLeft(r.toTwosComplement(t).round().toString(16),e)},a=function(t){return r.fromAscii(t,o.ETH_PADDING).substr(2)},u=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},s=function(t){return i(new n(t).times(new n(2).pow(128)))},c=function(t){return"1"===new n(t.substr(0,1),16).toString(2).substr(0,1)},l=function(t){return t=t||"0",c(t)?new n(t,16).minus(new n("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new n(t,16)},f=function(t){return t=t||"0",new n(t,16)},p=function(t){return l(t).dividedBy(new n(2).pow(128))},m=function(t){return f(t).dividedBy(new n(2).pow(128))},h=function(t){return"0x"+t},d=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},g=function(t){return r.toAscii(t)},v=function(t){return"0x"+t.slice(t.length-40,t.length)};e.exports={formatInputInt:i,formatInputString:a,formatInputBool:u,formatInputReal:s,formatOutputInt:l,formatOutputUInt:f,formatOutputReal:p,formatOutputUReal:m,formatOutputHash:h,formatOutputBool:d,formatOutputString:g,formatOutputAddress:v}},{"../utils/config":5,"../utils/utils":6,"bignumber.js":"bignumber.js"}],3:[function(t,e){var n=t("./formatters"),r=function(t){return function(e){return 0===e.indexOf(t)}},o=function(t){return function(e){return t===e}},i=function(){return[{type:r("uint"),format:n.formatInputInt},{type:r("int"),format:n.formatInputInt},{type:r("bytes"),format:n.formatInputString},{type:r("real"),format:n.formatInputReal},{type:r("ureal"),format:n.formatInputReal},{type:o("address"),format:n.formatInputInt},{type:o("bool"),format:n.formatInputBool}]},a=function(){return[{type:r("uint"),format:n.formatOutputUInt},{type:r("int"),format:n.formatOutputInt},{type:r("bytes"),format:n.formatOutputString},{type:r("real"),format:n.formatOutputReal},{type:r("ureal"),format:n.formatOutputUReal},{type:o("address"),format:n.formatOutputAddress},{type:o("bool"),format:n.formatOutputBool}]};e.exports={prefixedType:r,namedType:o,inputTypes:i,outputTypes:a}},{"./formatters":2}],4:[function(t,e,n){"use strict";n.XMLHttpRequest="undefined"==typeof XMLHttpRequest?{}:XMLHttpRequest},{}],5:[function(t,e){var n=t("bignumber.js"),r=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];e.exports={ETH_PADDING:32,ETH_SIGNATURE_LENGTH:4,ETH_UNITS:r,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:n.ROUND_DOWN},ETH_POLLING_TIMEOUT:1e3,ETH_DEFAULTBLOCK:"latest"}},{"bignumber.js":"bignumber.js"}],6:[function(t,e){var n=t("bignumber.js"),r={wei:"1",kwei:"1000",ada:"1000",mwei:"1000000",babbage:"1000000",gwei:"1000000000",shannon:"1000000000",szabo:"1000000000000",finney:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",einstein:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"},o=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},i=function(t,e){for(var n=!1,r=0;rn;n+=2){var o=parseInt(t.substr(n,2),16);if(0===o)break;e+=String.fromCharCode(o)}return e},u=function(t){for(var e="",n=0;n1?(t[n[0]]=t[n[0]]||{},t[n[0]][n[1]]=e):t[n[0]]=e},i.prototype.toPayload=function(t){var e=this.getCall(t),n=this.extractCallback(t),r=this.formatInput(t);return this.validateArgs(r),{method:e,params:r,callback:n}},i.prototype.send=function(){var t=this.toPayload(Array.prototype.slice.call(arguments));if(t.callback){var e=this;return n.getInstance().sendAsync(t,function(n,r){t.callback(null,e.formatOutput(r))})}return this.formatOutput(n.getInstance().send(t))},e.exports=i},{"../utils/utils":6,"./errors":11,"./requestmanager":22}],19:[function(t,e){var n=t("../utils/utils"),r=t("./property"),o=[],i=[new r({name:"listening",getter:"net_listening"}),new r({name:"peerCount",getter:"net_peerCount",outputFormatter:n.toDecimal})];e.exports={methods:o,properties:i}},{"../utils/utils":6,"./property":20}],20:[function(t,e){var n=t("./requestmanager"),r=function(t){this.name=t.name,this.getter=t.getter,this.setter=t.setter,this.outputFormatter=t.outputFormatter,this.inputFormatter=t.inputFormatter};r.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter(t):t},r.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t?this.outputFormatter(t):t},r.prototype.attachToObject=function(t){var e={get:this.get.bind(this),set:this.set.bind(this)},n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},Object.defineProperty(t[n[0]],n[1],e)):Object.defineProperty(t,n[0],e)},r.prototype.get=function(){return this.formatOutput(n.getInstance().send({method:this.getter}))},r.prototype.set=function(t){return n.getInstance().send({method:this.setter,params:[this.formatInput(t)]})},e.exports=r},{"./requestmanager":22}],21:[function(t,e){var n=function(){};n.prototype.send=function(t){var e=navigator.qt.callMethod(JSON.stringify(t));return JSON.parse(e)},e.exports=n},{}],22:[function(t,e){var n=t("./jsonrpc"),r=t("../utils/utils"),o=t("../utils/config"),i=t("./errors"),a=function(t){return arguments.callee._singletonInstance?arguments.callee._singletonInstance:(arguments.callee._singletonInstance=this,this.provider=t,this.polls=[],this.timeout=null,void this.poll())};a.getInstance=function(){var t=new a;return t},a.prototype.send=function(t){if(!this.provider)return console.error(i.InvalidProvider),null;var e=n.getInstance().toPayload(t.method,t.params),r=this.provider.send(e);if(!n.getInstance().isValidResponse(r))throw i.InvalidResponse(r);return r.result},a.prototype.sendAsync=function(t,e){if(!this.provider)return e(i.InvalidProvider);var r=n.getInstance().toPayload(t.method,t.params);this.provider.sendAsync(r,function(t,r){return t?e(t):n.getInstance().isValidResponse(r)?void e(null,r.result):e(i.InvalidResponse(r))})},a.prototype.setProvider=function(t){this.provider=t},a.prototype.startPolling=function(t,e,n,r){this.polls.push({data:t,id:e,callback:n,uninstall:r})},a.prototype.stopPolling=function(t){for(var e=this.polls.length;e--;){var n=this.polls[e];n.id===t&&this.polls.splice(e,1)}},a.prototype.reset=function(){this.polls.forEach(function(t){t.uninstall(t.id)}),this.polls=[],this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.poll()},a.prototype.poll=function(){if(this.timeout=setTimeout(this.poll.bind(this),o.ETH_POLLING_TIMEOUT),this.polls.length){if(!this.provider)return void console.error(i.InvalidProvider);var t=n.getInstance().toBatchPayload(this.polls.map(function(t){return t.data})),e=this;this.provider.sendAsync(t,function(t,o){if(!t){if(!r.isArray(o))throw i.InvalidResponse(o);o.map(function(t,n){return t.callback=e.polls[n].callback,t}).filter(function(t){var e=n.getInstance().isValidResponse(t);return e||t.callback(i.InvalidResponse(t)),e}).filter(function(t){return r.isArray(t.result)&&t.result.length>0}).forEach(function(t){t.callback(null,t.result)})}})}},e.exports=a},{"../utils/config":5,"../utils/utils":6,"./errors":11,"./jsonrpc":17}],23:[function(t,e){var n=t("./method"),r=t("./formatters"),o=new n({name:"post",call:"shh_post",params:1,inputFormatter:r.inputPostFormatter}),i=new n({name:"newIdentity",call:"shh_newIdentity",params:0}),a=new n({name:"hasIdentity",call:"shh_hasIdentity",params:1}),u=new n({name:"newGroup",call:"shh_newGroup",params:0}),s=new n({name:"addToGroup",call:"shh_addToGroup",params:0}),c=[o,i,a,u,s];e.exports={methods:c}},{"./formatters":15,"./method":18}],24:[function(t,e){var n=t("../web3"),r=t("../utils/config"),o=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*r.ETH_SIGNATURE_LENGTH)},i=function(t){return n.sha3(n.fromAscii(t))};e.exports={functionSignatureFromAscii:o,eventSignatureFromAscii:i}},{"../utils/config":5,"../web3":8}],25:[function(t,e){var n=t("./method"),r=function(){var t=function(t){return"string"==typeof t[0]?"eth_newBlockFilter":"eth_newFilter"},e=new n({name:"newFilter",call:t,params:1}),r=new n({name:"uninstallFilter",call:"eth_uninstallFilter",params:1}),o=new n({name:"getLogs",call:"eth_getFilterLogs",params:1}),i=new n({name:"poll",call:"eth_getFilterChanges",params:1});return[e,r,o,i]},o=function(){var t=new n({name:"newFilter",call:"shh_newFilter",params:1}),e=new n({name:"uninstallFilter",call:"shh_uninstallFilter",params:1}),r=new n({name:"getLogs",call:"shh_getMessages",params:1}),o=new n({name:"poll",call:"shh_getFilterChanges",params:1});return[t,e,r,o]};e.exports={eth:r,shh:o}},{"./method":18}],26:[function(){},{}],"bignumber.js":[function(t,e){"use strict";e.exports=BigNumber},{}],web3:[function(t,e){if("undefined"!=typeof n)var n;n=t("./lib/web3"),n.providers.HttpProvider=t("./lib/web3/httpprovider"),n.providers.QtSyncProvider=t("./lib/web3/qtsync"),n.eth.contract=t("./lib/web3/contract"),n.abi=t("./lib/solidity/abi"),e.exports=n},{"./lib/solidity/abi":1,"./lib/web3":8,"./lib/web3/contract":9,"./lib/web3/httpprovider":16,"./lib/web3/qtsync":21}]},{},["web3"]);
\ No newline at end of file
diff --git a/libjsqrc/ethereumjs/dist/web3.js b/libjsqrc/ethereumjs/dist/web3.js
new file mode 100644
index 000000000..c6faf34e3
--- /dev/null
+++ b/libjsqrc/ethereumjs/dist/web3.js
@@ -0,0 +1,5548 @@
+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.
+*/
+/** @file abi.js
+ * @authors:
+ * Marek Kotewicz
+ * Gav Wood
+ * @date 2014
+ */
+
+var utils = require('../utils/utils');
+var c = require('../utils/config');
+var types = require('./types');
+var f = require('./formatters');
+
+/**
+ * throw incorrect type error
+ *
+ * @method throwTypeError
+ * @param {String} type
+ * @throws incorrect type error
+ */
+var throwTypeError = function (type) {
+ throw new Error('parser does not support type: ' + type);
+};
+
+/** This method should be called if we want to check if givent type is an array type
+ *
+ * @method isArrayType
+ * @param {String} type name
+ * @returns {Boolean} true if it is, otherwise false
+ */
+var isArrayType = function (type) {
+ return type.slice(-2) === '[]';
+};
+
+/**
+ * This method should be called to return dynamic type length in hex
+ *
+ * @method dynamicTypeBytes
+ * @param {String} type
+ * @param {String|Array} dynamic type
+ * @return {String} length of dynamic type in hex or empty string if type is not dynamic
+ */
+var dynamicTypeBytes = function (type, value) {
+ // TODO: decide what to do with array of strings
+ if (isArrayType(type) || type === 'bytes')
+ return f.formatInputInt(value.length);
+ return "";
+};
+
+var inputTypes = types.inputTypes();
+
+/**
+ * Formats input params to bytes
+ *
+ * @method formatInput
+ * @param {Array} abi inputs of method
+ * @param {Array} params that will be formatted to bytes
+ * @returns bytes representation of input params
+ */
+var formatInput = function (inputs, params) {
+ var bytes = "";
+ var toAppendConstant = "";
+ var toAppendArrayContent = "";
+
+ /// first we iterate in search for dynamic
+ inputs.forEach(function (input, index) {
+ bytes += dynamicTypeBytes(input.type, params[index]);
+ });
+
+ inputs.forEach(function (input, i) {
+ /*jshint maxcomplexity:5 */
+ var typeMatch = false;
+ for (var j = 0; j < inputTypes.length && !typeMatch; j++) {
+ typeMatch = inputTypes[j].type(inputs[i].type, params[i]);
+ }
+ if (!typeMatch) {
+ throwTypeError(inputs[i].type);
+ }
+
+ var formatter = inputTypes[j - 1].format;
+
+ if (isArrayType(inputs[i].type))
+ toAppendArrayContent += params[i].reduce(function (acc, curr) {
+ return acc + formatter(curr);
+ }, "");
+ else if (inputs[i].type === 'bytes')
+ toAppendArrayContent += formatter(params[i]);
+ else
+ toAppendConstant += formatter(params[i]);
+ });
+
+ bytes += toAppendConstant + toAppendArrayContent;
+
+ return bytes;
+};
+
+/**
+ * This method should be called to predict the length of dynamic type
+ *
+ * @method dynamicBytesLength
+ * @param {String} type
+ * @returns {Number} length of dynamic type, 0 or multiplication of ETH_PADDING (32)
+ */
+var dynamicBytesLength = function (type) {
+ if (isArrayType(type) || type === 'bytes')
+ return c.ETH_PADDING * 2;
+ return 0;
+};
+
+var outputTypes = types.outputTypes();
+
+/**
+ * Formats output bytes back to param list
+ *
+ * @method formatOutput
+ * @param {Array} abi outputs of method
+ * @param {String} bytes represention of output
+ * @returns {Array} output params
+ */
+var formatOutput = function (outs, output) {
+
+ output = output.slice(2);
+ var result = [];
+ var padding = c.ETH_PADDING * 2;
+
+ var dynamicPartLength = outs.reduce(function (acc, curr) {
+ return acc + dynamicBytesLength(curr.type);
+ }, 0);
+
+ var dynamicPart = output.slice(0, dynamicPartLength);
+ output = output.slice(dynamicPartLength);
+
+ outs.forEach(function (out, i) {
+ /*jshint maxcomplexity:6 */
+ var typeMatch = false;
+ for (var j = 0; j < outputTypes.length && !typeMatch; j++) {
+ typeMatch = outputTypes[j].type(outs[i].type);
+ }
+
+ if (!typeMatch) {
+ throwTypeError(outs[i].type);
+ }
+
+ var formatter = outputTypes[j - 1].format;
+ if (isArrayType(outs[i].type)) {
+ var size = f.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 (types.prefixedType('bytes')(outs[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;
+};
+
+/**
+ * Should be called to create input parser for contract with given abi
+ *
+ * @method inputParser
+ * @param {Array} contract abi
+ * @returns {Object} input parser object for given json abi
+ * TODO: refactor creating the parser, do not double logic from contract
+ */
+var inputParser = function (json) {
+ var parser = {};
+ json.forEach(function (method) {
+ var displayName = utils.extractDisplayName(method.name);
+ var typeName = utils.extractTypeName(method.name);
+
+ var impl = function () {
+ var params = Array.prototype.slice.call(arguments);
+ return formatInput(method.inputs, params);
+ };
+
+ if (parser[displayName] === undefined) {
+ parser[displayName] = impl;
+ }
+
+ parser[displayName][typeName] = impl;
+ });
+
+ return parser;
+};
+
+/**
+ * Should be called to create output parser for contract with given abi
+ *
+ * @method outputParser
+ * @param {Array} contract abi
+ * @returns {Object} output parser for given json abi
+ */
+var outputParser = function (json) {
+ var parser = {};
+ json.forEach(function (method) {
+
+ var displayName = utils.extractDisplayName(method.name);
+ var typeName = utils.extractTypeName(method.name);
+
+ var impl = function (output) {
+ return formatOutput(method.outputs, output);
+ };
+
+ if (parser[displayName] === undefined) {
+ parser[displayName] = impl;
+ }
+
+ parser[displayName][typeName] = impl;
+ });
+
+ return parser;
+};
+
+module.exports = {
+ inputParser: inputParser,
+ outputParser: outputParser,
+ formatInput: formatInput,
+ formatOutput: formatOutput
+};
+
+},{"../utils/config":6,"../utils/utils":7,"./formatters":2,"./types":3}],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 .
+*/
+/** @file formatters.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+var BigNumber = require('bignumber.js');
+var utils = require('../utils/utils');
+var c = require('../utils/config');
+
+/**
+ * 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
+ *
+ * @method formatInputInt
+ * @param {String|Number|BigNumber} value that needs to be formatted
+ * @returns {String} right-aligned byte representation of int
+ */
+var formatInputInt = function (value) {
+ var padding = c.ETH_PADDING * 2;
+ BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
+ return utils.padLeft(utils.toTwosComplement(value).round().toString(16), padding);
+};
+
+/**
+ * Formats input value to byte representation of string
+ *
+ * @method formatInputString
+ * @param {String}
+ * @returns {String} left-algined byte representation of string
+ */
+var formatInputString = function (value) {
+ return utils.fromAscii(value, c.ETH_PADDING).substr(2);
+};
+
+/**
+ * Formats input value to byte representation of bool
+ *
+ * @method formatInputBool
+ * @param {Boolean}
+ * @returns {String} 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
+ *
+ * @method formatInputReal
+ * @param {String|Number|BigNumber}
+ * @returns {String} byte representation of real
+ */
+var formatInputReal = function (value) {
+ return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
+};
+
+/**
+ * Check if input value is negative
+ *
+ * @method signedIsNegative
+ * @param {String} value is hex format
+ * @returns {Boolean} 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 right-aligned output bytes to int
+ *
+ * @method formatOutputInt
+ * @param {String} bytes
+ * @returns {BigNumber} right-aligned output bytes formatted to big number
+ */
+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 right-aligned output bytes to uint
+ *
+ * @method formatOutputUInt
+ * @param {String} bytes
+ * @returns {BigNumeber} right-aligned output bytes formatted to uint
+ */
+var formatOutputUInt = function (value) {
+ value = value || "0";
+ return new BigNumber(value, 16);
+};
+
+/**
+ * Formats right-aligned output bytes to real
+ *
+ * @method formatOutputReal
+ * @param {String}
+ * @returns {BigNumber} input bytes formatted to real
+ */
+var formatOutputReal = function (value) {
+ return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128));
+};
+
+/**
+ * Formats right-aligned output bytes to ureal
+ *
+ * @method formatOutputUReal
+ * @param {String}
+ * @returns {BigNumber} input bytes formatted to ureal
+ */
+var formatOutputUReal = function (value) {
+ return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128));
+};
+
+/**
+ * Should be used to format output hash
+ *
+ * @method formatOutputHash
+ * @param {String}
+ * @returns {String} right-aligned output bytes formatted to hex
+ */
+var formatOutputHash = function (value) {
+ return "0x" + value;
+};
+
+/**
+ * Should be used to format output bool
+ *
+ * @method formatOutputBool
+ * @param {String}
+ * @returns {Boolean} right-aligned input bytes formatted to bool
+ */
+var formatOutputBool = function (value) {
+ return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
+};
+
+/**
+ * Should be used to format output string
+ *
+ * @method formatOutputString
+ * @param {Sttring} left-aligned hex representation of string
+ * @returns {String} ascii string
+ */
+var formatOutputString = function (value) {
+ return utils.toAscii(value);
+};
+
+/**
+ * Should be used to format output address
+ *
+ * @method formatOutputAddress
+ * @param {String} right-aligned input bytes
+ * @returns {String} address
+ */
+var formatOutputAddress = function (value) {
+ return "0x" + value.slice(value.length - 40, value.length);
+};
+
+module.exports = {
+ formatInputInt: formatInputInt,
+ formatInputString: formatInputString,
+ formatInputBool: formatInputBool,
+ formatInputReal: formatInputReal,
+ formatOutputInt: formatOutputInt,
+ formatOutputUInt: formatOutputUInt,
+ formatOutputReal: formatOutputReal,
+ formatOutputUReal: formatOutputUReal,
+ formatOutputHash: formatOutputHash,
+ formatOutputBool: formatOutputBool,
+ formatOutputString: formatOutputString,
+ formatOutputAddress: formatOutputAddress
+};
+
+
+},{"../utils/config":6,"../utils/utils":7,"bignumber.js":"bignumber.js"}],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 .
+*/
+/** @file types.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+var f = require('./formatters');
+
+/// @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;
+ };
+};
+
+/// Setups input formatters for solidity types
+/// @returns an array of input formatters
+var inputTypes = function () {
+
+ return [
+ { type: prefixedType('uint'), format: f.formatInputInt },
+ { type: prefixedType('int'), format: f.formatInputInt },
+ { type: prefixedType('bytes'), format: f.formatInputString },
+ { type: prefixedType('real'), format: f.formatInputReal },
+ { type: prefixedType('ureal'), format: f.formatInputReal },
+ { type: namedType('address'), format: f.formatInputInt },
+ { type: namedType('bool'), format: f.formatInputBool }
+ ];
+};
+
+/// Setups output formaters for solidity types
+/// @returns an array of output formatters
+var outputTypes = function () {
+
+ return [
+ { type: prefixedType('uint'), format: f.formatOutputUInt },
+ { type: prefixedType('int'), format: f.formatOutputInt },
+ { type: prefixedType('bytes'), format: f.formatOutputString },
+ { type: prefixedType('real'), format: f.formatOutputReal },
+ { type: prefixedType('ureal'), format: f.formatOutputUReal },
+ { type: namedType('address'), format: f.formatOutputAddress },
+ { type: namedType('bool'), format: f.formatOutputBool }
+ ];
+};
+
+module.exports = {
+ prefixedType: prefixedType,
+ namedType: namedType,
+ inputTypes: inputTypes,
+ outputTypes: outputTypes
+};
+
+
+},{"./formatters":2}],4:[function(require,module,exports){
+'use strict';
+
+module.exports = BigNumber; // jshint ignore:line
+
+
+},{}],5:[function(require,module,exports){
+'use strict';
+
+// go env doesn't have and need XMLHttpRequest
+if (typeof XMLHttpRequest === 'undefined') {
+ exports.XMLHttpRequest = {};
+} else {
+ exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
+}
+
+
+},{}],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 .
+*/
+/** @file config.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+/**
+ * Utils
+ *
+ * @module utils
+ */
+
+/**
+ * Utility functions
+ *
+ * @class [utils] config
+ * @constructor
+ */
+
+/// required to define ETH_BIGNUMBER_ROUNDING_MODE
+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'
+];
+
+module.exports = {
+ ETH_PADDING: 32,
+ ETH_SIGNATURE_LENGTH: 4,
+ ETH_UNITS: ETH_UNITS,
+ ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
+ ETH_POLLING_TIMEOUT: 1000,
+ ETH_DEFAULTBLOCK: 'latest'
+};
+
+
+},{"bignumber.js":"bignumber.js"}],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 .
+*/
+/** @file utils.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+/**
+ * Utils
+ *
+ * @module utils
+ */
+
+/**
+ * Utility functions
+ *
+ * @class [utils] utils
+ * @constructor
+ */
+
+var BigNumber = require('bignumber.js');
+
+var unitMap = {
+ 'wei': '1',
+ 'kwei': '1000',
+ 'ada': '1000',
+ 'mwei': '1000000',
+ 'babbage': '1000000',
+ 'gwei': '1000000000',
+ 'shannon': '1000000000',
+ 'szabo': '1000000000000',
+ 'finney': '1000000000000000',
+ 'ether': '1000000000000000000',
+ 'kether': '1000000000000000000000',
+ 'grand': '1000000000000000000000',
+ 'einstein': '1000000000000000000000',
+ 'mether': '1000000000000000000000000',
+ 'gether': '1000000000000000000000000000',
+ 'tether': '1000000000000000000000000000000'
+};
+
+/**
+ * Should be called to pad string to expected length
+ *
+ * @method padLeft
+ * @param {String} string to be padded
+ * @param {Number} characters that result string should have
+ * @param {String} sign, by default 0
+ * @returns {String} right aligned string
+ */
+var padLeft = function (string, chars, sign) {
+ return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
+};
+
+/** Finds first index of array element matching pattern
+ *
+ * @method findIndex
+ * @param {Array}
+ * @param {Function} pattern
+ * @returns {Number} 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;
+};
+
+/**
+ * Should be called to get sting from it's hex representation
+ *
+ * @method toAscii
+ * @param {String} string in hex
+ * @returns {String} ascii string representation of hex value
+ */
+var 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;
+};
+
+/**
+ * Shold be called to get hex representation (prefixed by 0x) of ascii string
+ *
+ * @method fromAscii
+ * @param {String} string
+ * @returns {String} hex representation of input string
+ */
+var toHexNative = 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;
+};
+
+/**
+ * Shold be called to get hex representation (prefixed by 0x) of ascii string
+ *
+ * @method fromAscii
+ * @param {String} string
+ * @param {Number} optional padding
+ * @returns {String} hex representation of input string
+ */
+var fromAscii = function(str, pad) {
+ pad = pad === undefined ? 0 : pad;
+ var hex = toHexNative(str);
+ while (hex.length < pad*2)
+ hex += "00";
+ return "0x" + hex;
+};
+
+/**
+ * Should be called to get display name of contract function
+ *
+ * @method extractDisplayName
+ * @param {String} name of function/event
+ * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
+ */
+var extractDisplayName = function (name) {
+ var length = name.indexOf('(');
+ return length !== -1 ? name.substr(0, length) : name;
+};
+
+/// @returns overloaded part of function/event name
+var extractTypeName = function (name) {
+ /// TODO: make it invulnerable
+ var length = name.indexOf('(');
+ return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
+};
+
+/**
+ * Filters all functions from input abi
+ *
+ * @method filterFunctions
+ * @param {Array} abi
+ * @returns {Array} abi array with filtered objects of type 'function'
+ */
+var filterFunctions = function (json) {
+ return json.filter(function (current) {
+ return current.type === 'function';
+ });
+};
+
+/**
+ * Filters all events from input abi
+ *
+ * @method filterEvents
+ * @param {Array} abi
+ * @returns {Array} abi array with filtered objects of type 'event'
+ */
+var filterEvents = function (json) {
+ return json.filter(function (current) {
+ return current.type === 'event';
+ });
+};
+
+/**
+ * Converts value to it's decimal representation in string
+ *
+ * @method toDecimal
+ * @param {String|Number|BigNumber}
+ * @return {String}
+ */
+var toDecimal = function (value) {
+ return toBigNumber(value).toNumber();
+};
+
+/**
+ * Converts value to it's hex representation
+ *
+ * @method fromDecimal
+ * @param {String|Number|BigNumber}
+ * @return {String}
+ */
+var fromDecimal = function (value) {
+ var number = toBigNumber(value);
+ var result = number.toString(16);
+
+ return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
+};
+
+/**
+ * Auto converts any given value into it's hex representation.
+ *
+ * And even stringifys objects before.
+ *
+ * @method toHex
+ * @param {String|Number|BigNumber|Object}
+ * @return {String}
+ */
+var toHex = function (val) {
+ /*jshint maxcomplexity:7 */
+
+ if (isBoolean(val))
+ return fromDecimal(+val);
+
+ if (isBigNumber(val))
+ return fromDecimal(val);
+
+ if (isObject(val))
+ return fromAscii(JSON.stringify(val));
+
+ // if its a negative number, pass it through fromDecimal
+ if (isString(val)) {
+ if (val.indexOf('-0x') === 0)
+ return fromDecimal(val);
+ else if (!isFinite(val))
+ return fromAscii(val);
+ }
+
+ return fromDecimal(val);
+};
+
+/**
+ * Returns value of unit in Wei
+ *
+ * @method getValueOfUnit
+ * @param {String} unit the unit to convert to, default ether
+ * @returns {BigNumber} value of the unit (in Wei)
+ * @throws error if the unit is not correct:w
+ */
+var getValueOfUnit = function (unit) {
+ unit = unit ? unit.toLowerCase() : 'ether';
+ var unitValue = unitMap[unit];
+ if (unitValue === undefined) {
+ throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
+ }
+ return new BigNumber(unitValue, 10);
+};
+
+/**
+ * Takes a number of wei and converts it to any other ether unit.
+ *
+ * Possible units are:
+ * - kwei/ada
+ * - mwei/babbage
+ * - gwei/shannon
+ * - szabo
+ * - finney
+ * - ether
+ * - kether/grand/einstein
+ * - mether
+ * - gether
+ * - tether
+ *
+ * @method fromWei
+ * @param {Number|String} number can be a number, number string or a HEX of a decimal
+ * @param {String} unit the unit to convert to, default ether
+ * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
+*/
+var fromWei = function(number, unit) {
+ var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
+
+ return isBigNumber(number) ? returnValue : returnValue.toString(10);
+};
+
+/**
+ * Takes a number of a unit and converts it to wei.
+ *
+ * Possible units are:
+ * - kwei/ada
+ * - mwei/babbage
+ * - gwei/shannon
+ * - szabo
+ * - finney
+ * - ether
+ * - kether/grand/einstein
+ * - mether
+ * - gether
+ * - tether
+ *
+ * @method toWei
+ * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
+ * @param {String} unit the unit to convert from, default ether
+ * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
+*/
+var toWei = function(number, unit) {
+ var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
+
+ return isBigNumber(number) ? returnValue : returnValue.toString(10);
+};
+
+/**
+ * Takes an input and transforms it into an bignumber
+ *
+ * @method toBigNumber
+ * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
+ * @return {BigNumber} BigNumber
+*/
+var toBigNumber = function(number) {
+ /*jshint maxcomplexity:5 */
+ number = number || 0;
+ if (isBigNumber(number))
+ return number;
+
+ if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
+ return new BigNumber(number.replace('0x',''), 16);
+ }
+
+ return new BigNumber(number.toString(10), 10);
+};
+
+/**
+ * Takes and input transforms it into bignumber and if it is negative value, into two's complement
+ *
+ * @method toTwosComplement
+ * @param {Number|String|BigNumber}
+ * @return {BigNumber}
+ */
+var toTwosComplement = function (number) {
+ var bigNumber = toBigNumber(number);
+ if (bigNumber.lessThan(0)) {
+ return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
+ }
+ return bigNumber;
+};
+
+/**
+ * Checks if the given string has proper length
+ *
+ * @method isAddress
+ * @param {String} address the given HEX adress
+ * @return {Boolean}
+*/
+var isAddress = function (address) {
+ return /^0x[0-9a-f]{40}$/.test(address);
+};
+
+/**
+ * Transforms given string to valid 20 bytes-length addres with 0x prefix
+ *
+ * @method toAddress
+ * @param {String} address
+ * @return {String} formatted address
+ */
+var toAddress = function (address) {
+ if (isAddress(address)) {
+ return address;
+ }
+
+ if (/^[0-9a-f]{40}$/.test(address)) {
+ return '0x' + address;
+ }
+
+ return '0x' + padLeft(toHex(address).substr(2), 40);
+};
+
+/**
+ * Returns true if object is BigNumber, otherwise false
+ *
+ * @method isBigNumber
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isBigNumber = function (object) {
+ return object instanceof BigNumber ||
+ (object && object.constructor && object.constructor.name === 'BigNumber');
+};
+
+/**
+ * Returns true if object is string, otherwise false
+ *
+ * @method isString
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isString = function (object) {
+ return typeof object === 'string' ||
+ (object && object.constructor && object.constructor.name === 'String');
+};
+
+/**
+ * Returns true if object is function, otherwise false
+ *
+ * @method isFunction
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isFunction = function (object) {
+ return typeof object === 'function';
+};
+
+/**
+ * Returns true if object is Objet, otherwise false
+ *
+ * @method isObject
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isObject = function (object) {
+ return typeof object === 'object';
+};
+
+/**
+ * Returns true if object is boolean, otherwise false
+ *
+ * @method isBoolean
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isBoolean = function (object) {
+ return typeof object === 'boolean';
+};
+
+/**
+ * Returns true if object is array, otherwise false
+ *
+ * @method isArray
+ * @param {Object}
+ * @return {Boolean}
+ */
+var isArray = function (object) {
+ return object instanceof Array;
+};
+
+/**
+ * Returns true if given string is valid json object
+ *
+ * @method isJson
+ * @param {String}
+ * @return {Boolean}
+ */
+var isJson = function (str) {
+ try {
+ return !!JSON.parse(str);
+ } catch (e) {
+ return false;
+ }
+};
+
+module.exports = {
+ padLeft: padLeft,
+ findIndex: findIndex,
+ toHex: toHex,
+ toDecimal: toDecimal,
+ fromDecimal: fromDecimal,
+ toAscii: toAscii,
+ fromAscii: fromAscii,
+ extractDisplayName: extractDisplayName,
+ extractTypeName: extractTypeName,
+ filterFunctions: filterFunctions,
+ filterEvents: filterEvents,
+ toWei: toWei,
+ fromWei: fromWei,
+ toBigNumber: toBigNumber,
+ toTwosComplement: toTwosComplement,
+ toAddress: toAddress,
+ isBigNumber: isBigNumber,
+ isAddress: isAddress,
+ isFunction: isFunction,
+ isString: isString,
+ isObject: isObject,
+ isBoolean: isBoolean,
+ isArray: isArray,
+ isJson: isJson
+};
+
+
+},{"bignumber.js":"bignumber.js"}],8:[function(require,module,exports){
+module.exports={
+ "version": "0.2.5"
+}
+
+},{}],9:[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 .
+*/
+/** @file web3.js
+ * @authors:
+ * Jeffrey Wilcke
+ * Marek Kotewicz
+ * Marian Oancea
+ * Fabian Vogelsteller
+ * Gav Wood
+ * @date 2014
+ */
+
+var version = require('./version.json');
+var net = require('./web3/net');
+var eth = require('./web3/eth');
+var db = require('./web3/db');
+var shh = require('./web3/shh');
+var watches = require('./web3/watches');
+var Filter = require('./web3/filter');
+var utils = require('./utils/utils');
+var formatters = require('./web3/formatters');
+var RequestManager = require('./web3/requestmanager');
+var c = require('./utils/config');
+var Method = require('./web3/method');
+var Property = require('./web3/property');
+
+var web3Methods = [
+ new Method({
+ name: 'sha3',
+ call: 'web3_sha3',
+ params: 1
+ })
+];
+
+var web3Properties = [
+ new Property({
+ name: 'version.client',
+ getter: 'web3_clientVersion'
+ }),
+ new Property({
+ name: 'version.network',
+ getter: 'net_version',
+ inputFormatter: utils.toDecimal
+ }),
+ new Property({
+ name: 'version.ethereum',
+ getter: 'eth_version',
+ inputFormatter: utils.toDecimal
+ }),
+ new Property({
+ name: 'version.whisper',
+ getter: 'shh_version',
+ inputFormatter: utils.toDecimal
+ })
+];
+
+/// 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) {
+ method.attachToObject(obj);
+ });
+};
+
+/// 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) {
+ property.attachToObject(obj);
+ });
+};
+
+/// setups web3 object, and it's in-browser executed methods
+var web3 = {};
+web3.providers = {};
+web3.version = {};
+web3.version.api = version.version;
+web3.eth = {};
+
+/*jshint maxparams:4 */
+web3.eth.filter = function (fil, eventParams, options, formatter) {
+
+ // if its event, treat it differently
+ // TODO: simplify and remove
+ if (fil._isEvent) {
+ return fil(eventParams, options);
+ }
+
+ // what outputLogFormatter? that's wrong
+ //return new Filter(fil, watches.eth(), formatters.outputLogFormatter);
+ return new Filter(fil, watches.eth(), formatter || formatters.outputLogFormatter);
+};
+/*jshint maxparams:3 */
+
+web3.shh = {};
+web3.shh.filter = function (fil) {
+ return new Filter(fil, watches.shh(), formatters.outputPostFormatter);
+};
+web3.net = {};
+web3.db = {};
+web3.setProvider = function (provider) {
+ RequestManager.getInstance().setProvider(provider);
+};
+web3.reset = function () {
+ RequestManager.getInstance().reset();
+};
+web3.toHex = utils.toHex;
+web3.toAscii = utils.toAscii;
+web3.fromAscii = utils.fromAscii;
+web3.toDecimal = utils.toDecimal;
+web3.fromDecimal = utils.fromDecimal;
+web3.toBigNumber = utils.toBigNumber;
+web3.toWei = utils.toWei;
+web3.fromWei = utils.fromWei;
+web3.isAddress = utils.isAddress;
+
+// ADD defaultblock
+Object.defineProperty(web3.eth, 'defaultBlock', {
+ get: function () {
+ return c.ETH_DEFAULTBLOCK;
+ },
+ set: function (val) {
+ c.ETH_DEFAULTBLOCK = val;
+ return c.ETH_DEFAULTBLOCK;
+ }
+});
+
+
+/// setups all api methods
+setupMethods(web3, web3Methods);
+setupProperties(web3, web3Properties);
+setupMethods(web3.net, net.methods);
+setupProperties(web3.net, net.properties);
+setupMethods(web3.eth, eth.methods);
+setupProperties(web3.eth, eth.properties);
+setupMethods(web3.db, db.methods);
+setupMethods(web3.shh, shh.methods);
+
+module.exports = web3;
+
+
+},{"./utils/config":6,"./utils/utils":7,"./version.json":8,"./web3/db":11,"./web3/eth":13,"./web3/filter":15,"./web3/formatters":16,"./web3/method":19,"./web3/net":20,"./web3/property":21,"./web3/requestmanager":23,"./web3/shh":24,"./web3/watches":26}],10:[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 .
+*/
+/** @file contract.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2014
+ */
+
+var web3 = require('../web3');
+var abi = require('../solidity/abi');
+var utils = require('../utils/utils');
+var eventImpl = require('./event');
+var signature = require('./signature');
+
+var addFunctionRelatedPropertiesToContract = function (contract) {
+
+ contract.call = function (options) {
+ contract._isTransaction = false;
+ contract._options = options;
+ return contract;
+ };
+
+ contract.sendTransaction = function (options) {
+ contract._isTransaction = true;
+ contract._options = options;
+ return contract;
+ };
+};
+
+var addFunctionsToContract = function (contract, desc, address) {
+ var inputParser = abi.inputParser(desc);
+ var outputParser = abi.outputParser(desc);
+
+ // create contract functions
+ utils.filterFunctions(desc).forEach(function (method) {
+
+ var displayName = utils.extractDisplayName(method.name);
+ var typeName = utils.extractTypeName(method.name);
+
+ var impl = function () {
+ /*jshint maxcomplexity:7 */
+ var params = Array.prototype.slice.call(arguments);
+ var sign = signature.functionSignatureFromAscii(method.name);
+ var parsed = inputParser[displayName][typeName].apply(null, params);
+
+ var options = contract._options || {};
+ options.to = address;
+ options.data = sign + parsed;
+
+ var isTransaction = contract._isTransaction === true || (contract._isTransaction !== false && !method.constant);
+ var collapse = options.collapse !== false;
+
+ // reset
+ contract._options = {};
+ contract._isTransaction = null;
+
+ if (isTransaction) {
+
+ // transactions do not have any output, cause we do not know, when they will be processed
+ web3.eth.sendTransaction(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 (contract[displayName] === undefined) {
+ contract[displayName] = impl;
+ }
+
+ contract[displayName][typeName] = impl;
+ });
+};
+
+var addEventRelatedPropertiesToContract = function (contract, desc, address) {
+ contract.address = address;
+ contract._onWatchEventResult = function (data) {
+ var matchingEvent = event.getMatchingEvent(utils.filterEvents(desc));
+ var parser = eventImpl.outputParser(matchingEvent);
+ return parser(data);
+ };
+
+ Object.defineProperty(contract, 'topics', {
+ get: function() {
+ return utils.filterEvents(desc).map(function (e) {
+ return signature.eventSignatureFromAscii(e.name);
+ });
+ }
+ });
+
+};
+
+var addEventsToContract = function (contract, desc, address) {
+ // create contract events
+ utils.filterEvents(desc).forEach(function (e) {
+
+ var impl = function () {
+ var params = Array.prototype.slice.call(arguments);
+ var sign = signature.eventSignatureFromAscii(e.name);
+ var event = eventImpl.inputParser(address, sign, e);
+ var o = event.apply(null, params);
+ var outputFormatter = function (data) {
+ var parser = eventImpl.outputParser(e);
+ return parser(data);
+ };
+ return web3.eth.filter(o, undefined, undefined, outputFormatter);
+ };
+
+ // this property should be used by eth.filter to check if object is an event
+ impl._isEvent = true;
+
+ var displayName = utils.extractDisplayName(e.name);
+ var typeName = utils.extractTypeName(e.name);
+
+ if (contract[displayName] === undefined) {
+ contract[displayName] = impl;
+ }
+
+ contract[displayName][typeName] = impl;
+
+ });
+};
+
+
+/**
+ * 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(abi); // creation of contract prototype
+ *
+ * var contractInstance = new MyContract('0x0123123121');
+ *
+ * contractInstance.myMethod('this is test string param for call'); // myMethod call (implicit, default)
+ * contractInstance.call().myMethod('this is test string param for call'); // myMethod call (explicit)
+ * contractInstance.sendTransaction().myMethod('this is test string param for transact'); // myMethod sendTransaction
+ *
+ * @param abi - abi json description of the contract, which is being created
+ * @returns contract object
+ */
+var contract = function (abi) {
+
+ // return prototype
+ return Contract.bind(null, abi);
+};
+
+function Contract(abi, address) {
+
+ // 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.
+ // TODO: we may not want to modify input params, maybe use copy instead?
+ abi.forEach(function (method) {
+ 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 result = {};
+ addFunctionRelatedPropertiesToContract(result);
+ addFunctionsToContract(result, abi, address);
+ addEventRelatedPropertiesToContract(result, abi, address);
+ addEventsToContract(result, abi, address);
+
+ return result;
+}
+
+module.exports = contract;
+
+
+},{"../solidity/abi":1,"../utils/utils":7,"../web3":9,"./event":14,"./signature":25}],11:[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 .
+*/
+/** @file db.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+var Method = require('./method');
+
+var putString = new Method({
+ name: 'putString',
+ call: 'db_putString',
+ params: 3
+});
+
+
+var getString = new Method({
+ name: 'getString',
+ call: 'db_getString',
+ params: 2
+});
+
+var putHex = new Method({
+ name: 'putHex',
+ call: 'db_putHex',
+ params: 3
+});
+
+var getHex = new Method({
+ name: 'getHex',
+ call: 'db_getHex',
+ params: 2
+});
+
+var methods = [
+ putString, getString, putHex, getHex
+];
+
+module.exports = {
+ methods: methods
+};
+
+},{"./method":19}],12:[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 .
+*/
+/**
+ * @file errors.js
+ * @author Marek Kotewicz
+ * @date 2015
+ */
+
+var utils = require('../utils/utils');
+
+module.exports = {
+ InvalidNumberOfParams: new Error('Invalid number of input parameters'),
+ InvalidProvider: new Error('Providor not set or invalid'),
+ InvalidResponse: function(result){
+ var message = 'Invalid JSON RPC response';
+
+ if(utils.isObject(result) && result.error && result.error.message) {
+ message = result.error.message;
+ }
+
+ return new Error(message);
+ }
+};
+
+
+},{"../utils/utils":7}],13:[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 .
+*/
+/**
+ * @file eth.js
+ * @author Marek Kotewicz
+ * @author Fabian Vogelsteller
+ * @date 2015
+ */
+
+/**
+ * Web3
+ *
+ * @module web3
+ */
+
+/**
+ * Eth methods and properties
+ *
+ * An example method object can look as follows:
+ *
+ * {
+ * name: 'getBlock',
+ * call: blockCall,
+ * params: 2,
+ * outputFormatter: formatters.outputBlockFormatter,
+ * inputFormatter: [ // can be a formatter funciton or an array of functions. Where each item in the array will be used for one parameter
+ * utils.toHex, // formats paramter 1
+ * function(param){ return !!param; } // formats paramter 2
+ * ]
+ * },
+ *
+ * @class [web3] eth
+ * @constructor
+ */
+
+"use strict";
+
+var formatters = require('./formatters');
+var utils = require('../utils/utils');
+var Method = require('./method');
+var Property = require('./property');
+
+var blockCall = function (args) {
+ return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
+};
+
+var transactionFromBlockCall = function (args) {
+ return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
+};
+
+var uncleCall = function (args) {
+ return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
+};
+
+var getBlockTransactionCountCall = function (args) {
+ return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
+};
+
+var uncleCountCall = function (args) {
+ return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
+};
+
+/// @returns an array of objects describing web3.eth api methods
+
+var getBalance = new Method({
+ name: 'getBalance',
+ call: 'eth_getBalance',
+ params: 2,
+ inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter],
+ outputFormatter: formatters.outputBigNumberFormatter
+});
+
+var getStorageAt = new Method({
+ name: 'getStorageAt',
+ call: 'eth_getStorageAt',
+ params: 3,
+ inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
+});
+
+var getCode = new Method({
+ name: 'getCode',
+ call: 'eth_getCode',
+ params: 2,
+ inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter]
+});
+
+var getBlock = new Method({
+ name: 'getBlock',
+ call: blockCall,
+ params: 2,
+ inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
+ outputFormatter: formatters.outputBlockFormatter
+});
+
+var getUncle = new Method({
+ name: 'getUncle',
+ call: uncleCall,
+ params: 3,
+ inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex, function (val) { return !!val; }],
+ outputFormatter: formatters.outputBlockFormatter,
+
+});
+
+var getCompilers = new Method({
+ name: 'getCompilers',
+ call: 'eth_getCompilers',
+ params: 0
+});
+
+var getBlockTransactionCount = new Method({
+ name: 'getBlockTransactionCount',
+ call: getBlockTransactionCountCall,
+ params: 1,
+ inputFormatter: [formatters.inputBlockNumberFormatter],
+ outputFormatter: utils.toDecimal
+});
+
+var getBlockUncleCount = new Method({
+ name: 'getBlockUncleCount',
+ call: uncleCountCall,
+ params: 1,
+ inputFormatter: [formatters.inputBlockNumberFormatter],
+ outputFormatter: utils.toDecimal
+});
+
+var getTransaction = new Method({
+ name: 'getTransaction',
+ call: 'eth_getTransactionByHash',
+ params: 1,
+ outputFormatter: formatters.outputTransactionFormatter
+});
+
+var getTransactionFromBlock = new Method({
+ name: 'getTransactionFromBlock',
+ call: transactionFromBlockCall,
+ params: 2,
+ inputFormatter: [utils.toHex, utils.toHex],
+ outputFormatter: formatters.outputTransactionFormatter
+});
+
+var getTransactionCount = new Method({
+ name: 'getTransactionCount',
+ call: 'eth_getTransactionCount',
+ params: 2,
+ inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
+ outputFormatter: utils.toDecimal
+});
+
+var sendTransaction = new Method({
+ name: 'sendTransaction',
+ call: 'eth_sendTransaction',
+ params: 1,
+ inputFormatter: [formatters.inputTransactionFormatter]
+});
+
+var call = new Method({
+ name: 'call',
+ call: 'eth_call',
+ params: 2,
+ inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter]
+});
+
+var compileSolidity = new Method({
+ name: 'compile.solidity',
+ call: 'eth_compileSolidity',
+ params: 1
+});
+
+var compileLLL = new Method({
+ name: 'compile.lll',
+ call: 'eth_compileLLL',
+ params: 1
+});
+
+var compileSerpent = new Method({
+ name: 'compile.serpent',
+ call: 'eth_compileSerpent',
+ params: 1
+});
+
+var flush = new Method({
+ name: 'flush',
+ call: 'eth_flush',
+ params: 0
+});
+
+var methods = [
+ getBalance,
+ getStorageAt,
+ getCode,
+ getBlock,
+ getUncle,
+ getCompilers,
+ getBlockTransactionCount,
+ getBlockUncleCount,
+ getTransaction,
+ getTransactionFromBlock,
+ getTransactionCount,
+ call,
+ sendTransaction,
+ compileSolidity,
+ compileLLL,
+ compileSerpent,
+ flush
+];
+
+/// @returns an array of objects describing web3.eth api properties
+
+
+
+var properties = [
+ new Property({
+ name: 'coinbase',
+ getter: 'eth_coinbase'
+ }),
+ new Property({
+ name: 'mining',
+ getter: 'eth_mining'
+ }),
+ new Property({
+ name: 'gasPrice',
+ getter: 'eth_gasPrice',
+ outputFormatter: formatters.inputNumberFormatter
+ }),
+ new Property({
+ name: 'accounts',
+ getter: 'eth_accounts'
+ }),
+ new Property({
+ name: 'blockNumber',
+ getter: 'eth_blockNumber',
+ outputFormatter: utils.toDecimal
+ })
+];
+
+module.exports = {
+ methods: methods,
+ properties: properties
+};
+
+
+},{"../utils/utils":7,"./formatters":16,"./method":19,"./property":21}],14:[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 .
+*/
+/** @file event.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2014
+ */
+
+var abi = require('../solidity/abi');
+var utils = require('../utils/utils');
+var signature = require('./signature');
+
+/// filter inputs array && returns only indexed (or not) inputs
+/// @param inputs array
+/// @param bool if result should be an array of indexed params on not
+/// @returns array of (not?) indexed params
+var filterInputs = function (inputs, indexed) {
+ return inputs.filter(function (current) {
+ return current.indexed === indexed;
+ });
+};
+
+var inputWithName = function (inputs, name) {
+ var index = utils.findIndex(inputs, function (input) {
+ return input.name === name;
+ });
+
+ if (index === -1) {
+ console.error('indexed param with name ' + name + ' not found');
+ return undefined;
+ }
+ return inputs[index];
+};
+
+var indexedParamsToTopics = function (event, indexed) {
+ // sort keys?
+ return Object.keys(indexed).map(function (key) {
+ var inputs = [inputWithName(filterInputs(event.inputs, true), key)];
+
+ var value = indexed[key];
+ if (value instanceof Array) {
+ return value.map(function (v) {
+ return abi.formatInput(inputs, [v]);
+ });
+ }
+ return '0x' + abi.formatInput(inputs, [value]);
+ });
+};
+
+var inputParser = function (address, sign, event) {
+
+ // valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.filter'
+ return function (indexed, options) {
+ var o = options || {};
+ o.address = address;
+ o.topics = [];
+ o.topics.push(sign);
+ if (indexed) {
+ o.topics = o.topics.concat(indexedParamsToTopics(event, indexed));
+ }
+ return o;
+ };
+};
+
+var getArgumentsObject = function (inputs, indexed, notIndexed) {
+ var indexedCopy = indexed.slice();
+ var notIndexedCopy = notIndexed.slice();
+ return inputs.reduce(function (acc, current) {
+ var value;
+ if (current.indexed)
+ value = indexedCopy.splice(0, 1)[0];
+ else
+ value = notIndexedCopy.splice(0, 1)[0];
+
+ acc[current.name] = value;
+ return acc;
+ }, {});
+};
+
+var outputParser = function (event) {
+
+ return function (output) {
+ var result = {
+ event: utils.extractDisplayName(event.name),
+ number: output.number,
+ hash: output.hash,
+ args: {}
+ };
+
+ if (!output.topics) {
+ return result;
+ }
+ output.data = output.data || '';
+
+ var indexedOutputs = filterInputs(event.inputs, true);
+ var indexedData = "0x" + output.topics.slice(1, output.topics.length).map(function (topics) { return topics.slice(2); }).join("");
+ var indexedRes = abi.formatOutput(indexedOutputs, indexedData);
+
+ var notIndexedOutputs = filterInputs(event.inputs, false);
+ var notIndexedRes = abi.formatOutput(notIndexedOutputs, output.data);
+
+ result.args = getArgumentsObject(event.inputs, indexedRes, notIndexedRes);
+
+ return result;
+ };
+};
+
+var getMatchingEvent = function (events, payload) {
+ for (var i = 0; i < events.length; i++) {
+ var sign = signature.eventSignatureFromAscii(events[i].name);
+ if (sign === payload.topics[0]) {
+ return events[i];
+ }
+ }
+ return undefined;
+};
+
+
+module.exports = {
+ inputParser: inputParser,
+ outputParser: outputParser,
+ getMatchingEvent: getMatchingEvent
+};
+
+
+},{"../solidity/abi":1,"../utils/utils":7,"./signature":25}],15:[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 .
+*/
+/** @file filter.js
+ * @authors:
+ * Jeffrey Wilcke
+ * Marek Kotewicz
+ * Marian Oancea
+ * Fabian Vogelsteller
+ * Gav Wood
+ * @date 2014
+ */
+
+var RequestManager = require('./requestmanager');
+var formatters = require('./formatters');
+var utils = require('../utils/utils');
+
+/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
+/// @param should be string or object
+/// @returns options string or object
+var getOptions = function (options) {
+
+ if (utils.isString(options)) {
+ return options;
+ }
+
+ options = options || {};
+
+ // make sure topics, get converted to hex
+ options.topics = options.topics || [];
+ options.topics = options.topics.map(function(topic){
+ return utils.toHex(topic);
+ });
+
+ // lazy load
+ return {
+ topics: options.topics,
+ to: options.to,
+ address: options.address,
+ fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
+ toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
+ };
+};
+
+var Filter = function (options, methods, formatter) {
+ var implementation = {};
+ methods.forEach(function (method) {
+ method.attachToObject(implementation);
+ });
+ this.options = getOptions(options);
+ this.implementation = implementation;
+ this.callbacks = [];
+ this.formatter = formatter;
+ this.filterId = this.implementation.newFilter(this.options);
+};
+
+Filter.prototype.watch = function (callback) {
+ this.callbacks.push(callback);
+ var self = this;
+
+ var onMessage = function (error, messages) {
+ if (error) {
+ return self.callbacks.forEach(function (callback) {
+ callback(error);
+ });
+ }
+
+ messages.forEach(function (message) {
+ message = self.formatter ? self.formatter(message) : message;
+ self.callbacks.forEach(function (callback) {
+ callback(null, message);
+ });
+ });
+ };
+
+ RequestManager.getInstance().startPolling({
+ method: this.implementation.poll.call,
+ params: [this.filterId],
+ }, this.filterId, onMessage, this.stopWatching.bind(this));
+};
+
+Filter.prototype.stopWatching = function () {
+ RequestManager.getInstance().stopPolling(this.filterId);
+ this.implementation.uninstallFilter(this.filterId);
+ this.callbacks = [];
+};
+
+Filter.prototype.get = function () {
+ var logs = this.implementation.getLogs(this.filterId);
+ var self = this;
+ return logs.map(function (log) {
+ return self.formatter ? self.formatter(log) : log;
+ });
+};
+
+module.exports = Filter;
+
+
+},{"../utils/utils":7,"./formatters":16,"./requestmanager":23}],16:[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 .
+*/
+/**
+ * @file formatters.js
+ * @author Marek Kotewicz
+ * @author Fabian Vogelsteller
+ * @date 2015
+ */
+
+var utils = require('../utils/utils');
+var config = require('../utils/config');
+
+/**
+ * Should the format output to a big number
+ *
+ * @method outputBigNumberFormatter
+ * @param {String|Number|BigNumber}
+ * @returns {BigNumber} object
+ */
+var outputBigNumberFormatter = function (number) {
+ return utils.toBigNumber(number);
+};
+
+var isPredefinedBlockNumber = function (blockNumber) {
+ return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
+};
+
+var inputDefaultBlockNumberFormatter = function (blockNumber) {
+ if (blockNumber === undefined) {
+ return config.ETH_DEFAULTBLOCK;
+ }
+ return inputBlockNumberFormatter(blockNumber);
+};
+
+var inputBlockNumberFormatter = function (blockNumber) {
+ if (blockNumber === undefined) {
+ return undefined;
+ } else if (isPredefinedBlockNumber(blockNumber)) {
+ return blockNumber;
+ }
+ return utils.toHex(blockNumber);
+};
+
+/**
+ * Formats the input of a transaction and converts all values to HEX
+ *
+ * @method inputTransactionFormatter
+ * @param {Object} transaction options
+ * @returns object
+*/
+var inputTransactionFormatter = function (options){
+
+ // make code -> data
+ if (options.code) {
+ options.data = options.code;
+ delete options.code;
+ }
+
+ ['gasPrice', 'gas', 'value'].filter(function (key) {
+ return options[key] !== undefined;
+ }).forEach(function(key){
+ options[key] = utils.fromDecimal(options[key]);
+ });
+
+ return options;
+};
+
+/**
+ * Formats the output of a transaction to its proper values
+ *
+ * @method outputTransactionFormatter
+ * @param {Object} transaction
+ * @returns {Object} transaction
+*/
+var outputTransactionFormatter = function (tx){
+ tx.blockNumber = utils.toDecimal(tx.blockNumber);
+ tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
+ tx.gas = utils.toDecimal(tx.gas);
+ tx.gasPrice = utils.toBigNumber(tx.gasPrice);
+ tx.value = utils.toBigNumber(tx.value);
+ return tx;
+};
+
+/**
+ * Formats the output of a block to its proper values
+ *
+ * @method outputBlockFormatter
+ * @param {Object} block object
+ * @returns {Object} block object
+*/
+var outputBlockFormatter = function(block) {
+
+ // transform to number
+ block.gasLimit = utils.toDecimal(block.gasLimit);
+ block.gasUsed = utils.toDecimal(block.gasUsed);
+ block.size = utils.toDecimal(block.size);
+ block.timestamp = utils.toDecimal(block.timestamp);
+ block.number = utils.toDecimal(block.number);
+
+ block.minGasPrice = utils.toBigNumber(block.minGasPrice);
+ block.difficulty = utils.toBigNumber(block.difficulty);
+ block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
+
+ if (utils.isArray(block.transactions)) {
+ block.transactions.forEach(function(item){
+ if(!utils.isString(item))
+ return outputTransactionFormatter(item);
+ });
+ }
+
+ return block;
+};
+
+/**
+ * Formats the output of a log
+ *
+ * @method outputLogFormatter
+ * @param {Object} log object
+ * @returns {Object} log
+*/
+var outputLogFormatter = function(log) {
+ if (log === null) { // 'pending' && 'latest' filters are nulls
+ return null;
+ }
+
+ log.blockNumber = utils.toDecimal(log.blockNumber);
+ log.transactionIndex = utils.toDecimal(log.transactionIndex);
+ log.logIndex = utils.toDecimal(log.logIndex);
+
+ return log;
+};
+
+/**
+ * Formats the input of a whisper post and converts all values to HEX
+ *
+ * @method inputPostFormatter
+ * @param {Object} transaction object
+ * @returns {Object}
+*/
+var inputPostFormatter = function(post) {
+
+ post.payload = utils.toHex(post.payload);
+ post.ttl = utils.fromDecimal(post.ttl);
+ post.priority = utils.fromDecimal(post.priority);
+
+ if(!utils.isArray(post.topics)) {
+ post.topics = [post.topics];
+ }
+
+ // format the following options
+ post.topics = post.topics.map(function(topic){
+ return utils.fromAscii(topic);
+ });
+
+ return post;
+};
+
+/**
+ * Formats the output of a received post message
+ *
+ * @method outputPostFormatter
+ * @param {Object}
+ * @returns {Object}
+ */
+var outputPostFormatter = function(post){
+
+ post.expiry = utils.toDecimal(post.expiry);
+ post.sent = utils.toDecimal(post.sent);
+ post.ttl = utils.toDecimal(post.ttl);
+ post.workProved = utils.toDecimal(post.workProved);
+ post.payloadRaw = post.payload;
+ post.payload = utils.toAscii(post.payload);
+
+ if (utils.isJson(post.payload)) {
+ post.payload = JSON.parse(post.payload);
+ }
+
+ // format the following options
+ post.topics = post.topics.map(function(topic){
+ return utils.toAscii(topic);
+ });
+
+ return post;
+};
+
+module.exports = {
+ inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
+ inputBlockNumberFormatter: inputBlockNumberFormatter,
+ inputTransactionFormatter: inputTransactionFormatter,
+ inputPostFormatter: inputPostFormatter,
+ outputBigNumberFormatter: outputBigNumberFormatter,
+ outputTransactionFormatter: outputTransactionFormatter,
+ outputBlockFormatter: outputBlockFormatter,
+ outputLogFormatter: outputLogFormatter,
+ outputPostFormatter: outputPostFormatter
+};
+
+
+},{"../utils/config":6,"../utils/utils":7}],17:[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 .
+*/
+/** @file httpprovider.js
+ * @authors:
+ * Marek Kotewicz
+ * Marian Oancea
+ * Fabian Vogelsteller
+ * @date 2014
+ */
+
+"use strict";
+
+var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
+
+var HttpProvider = function (host) {
+ this.host = host || 'http://localhost:8080';
+};
+
+HttpProvider.prototype.send = function (payload) {
+ var request = new XMLHttpRequest();
+
+ request.open('POST', this.host, false);
+ request.send(JSON.stringify(payload));
+
+ // check request.status
+ // TODO: throw an error here! it cannot silently fail!!!
+ //if (request.status !== 200) {
+ //return;
+ //}
+ return JSON.parse(request.responseText);
+};
+
+HttpProvider.prototype.sendAsync = function (payload, callback) {
+ var request = new XMLHttpRequest();
+ request.onreadystatechange = function() {
+ if (request.readyState === 4) {
+ // TODO: handle the error properly here!!!
+ callback(null, JSON.parse(request.responseText));
+ }
+ };
+
+ request.open('POST', this.host, true);
+ request.send(JSON.stringify(payload));
+};
+
+module.exports = HttpProvider;
+
+
+},{"xmlhttprequest":5}],18:[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 .
+*/
+/** @file jsonrpc.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+var Jsonrpc = function () {
+ // singleton pattern
+ if (arguments.callee._singletonInstance) {
+ return arguments.callee._singletonInstance;
+ }
+ arguments.callee._singletonInstance = this;
+
+ this.messageId = 1;
+};
+
+/**
+ * @return {Jsonrpc} singleton
+ */
+Jsonrpc.getInstance = function () {
+ var instance = new Jsonrpc();
+ return instance;
+};
+
+/**
+ * Should be called to valid json create payload object
+ *
+ * @method toPayload
+ * @param {Function} method of jsonrpc call, required
+ * @param {Array} params, an array of method params, optional
+ * @returns {Object} valid jsonrpc payload object
+ */
+Jsonrpc.prototype.toPayload = function (method, params) {
+ if (!method)
+ console.error('jsonrpc method should be specified!');
+
+ return {
+ jsonrpc: '2.0',
+ method: method,
+ params: params || [],
+ id: this.messageId++
+ };
+};
+
+/**
+ * Should be called to check if jsonrpc response is valid
+ *
+ * @method isValidResponse
+ * @param {Object}
+ * @returns {Boolean} true if response is valid, otherwise false
+ */
+Jsonrpc.prototype.isValidResponse = function (response) {
+ return !!response &&
+ !response.error &&
+ response.jsonrpc === '2.0' &&
+ typeof response.id === 'number' &&
+ response.result !== undefined; // only undefined is not valid json object
+};
+
+/**
+ * Should be called to create batch payload object
+ *
+ * @method toBatchPayload
+ * @param {Array} messages, an array of objects with method (required) and params (optional) fields
+ * @returns {Array} batch payload
+ */
+Jsonrpc.prototype.toBatchPayload = function (messages) {
+ var self = this;
+ return messages.map(function (message) {
+ return self.toPayload(message.method, message.params);
+ });
+};
+
+module.exports = Jsonrpc;
+
+
+},{}],19:[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 .
+*/
+/**
+ * @file method.js
+ * @author Marek Kotewicz
+ * @date 2015
+ */
+
+var RequestManager = require('./requestmanager');
+var utils = require('../utils/utils');
+var errors = require('./errors');
+
+var Method = function (options) {
+ this.name = options.name;
+ this.call = options.call;
+ this.params = options.params || 0;
+ this.inputFormatter = options.inputFormatter;
+ this.outputFormatter = options.outputFormatter;
+};
+
+/**
+ * Should be used to determine name of the jsonrpc method based on arguments
+ *
+ * @method getCall
+ * @param {Array} arguments
+ * @return {String} name of jsonrpc method
+ */
+Method.prototype.getCall = function (args) {
+ return utils.isFunction(this.call) ? this.call(args) : this.call;
+};
+
+/**
+ * Should be used to extract callback from array of arguments. Modifies input param
+ *
+ * @method extractCallback
+ * @param {Array} arguments
+ * @return {Function|Null} callback, if exists
+ */
+Method.prototype.extractCallback = function (args) {
+ if (utils.isFunction(args[args.length - 1])) {
+ return args.pop(); // modify the args array!
+ }
+ return null;
+};
+
+/**
+ * Should be called to check if the number of arguments is correct
+ *
+ * @method validateArgs
+ * @param {Array} arguments
+ * @throws {Error} if it is not
+ */
+Method.prototype.validateArgs = function (args) {
+ if (args.length !== this.params) {
+ throw errors.InvalidNumberOfParams;
+ }
+};
+
+/**
+ * Should be called to format input args of method
+ *
+ * @method formatInput
+ * @param {Array}
+ * @return {Array}
+ */
+Method.prototype.formatInput = function (args) {
+ if (!this.inputFormatter) {
+ return args;
+ }
+
+ return this.inputFormatter.map(function (formatter, index) {
+ return formatter ? formatter(args[index]) : args[index];
+ });
+};
+
+/**
+ * Should be called to format output(result) of method
+ *
+ * @method formatOutput
+ * @param {Object}
+ * @return {Object}
+ */
+Method.prototype.formatOutput = function (result) {
+ return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;
+};
+
+/**
+ * Should attach function to method
+ *
+ * @method attachToObject
+ * @param {Object}
+ * @param {Function}
+ */
+Method.prototype.attachToObject = function (obj) {
+ var func = this.send.bind(this);
+ func.call = this.call; // that's ugly. filter.js uses it
+ var name = this.name.split('.');
+ if (name.length > 1) {
+ obj[name[0]] = obj[name[0]] || {};
+ obj[name[0]][name[1]] = func;
+ } else {
+ obj[name[0]] = func;
+ }
+};
+
+/**
+ * Should create payload from given input args
+ *
+ * @method toPayload
+ * @param {Array} args
+ * @return {Object}
+ */
+Method.prototype.toPayload = function (args) {
+ var call = this.getCall(args);
+ var callback = this.extractCallback(args);
+ var params = this.formatInput(args);
+ this.validateArgs(params);
+
+ return {
+ method: call,
+ params: params,
+ callback: callback
+ };
+};
+
+/**
+ * Should send request to the API
+ *
+ * @method send
+ * @param list of params
+ * @return result
+ */
+Method.prototype.send = function () {
+ var payload = this.toPayload(Array.prototype.slice.call(arguments));
+ if (payload.callback) {
+ var self = this;
+ return RequestManager.getInstance().sendAsync(payload, function (err, result) {
+ payload.callback(null, self.formatOutput(result));
+ });
+ }
+ return this.formatOutput(RequestManager.getInstance().send(payload));
+};
+
+module.exports = Method;
+
+
+},{"../utils/utils":7,"./errors":12,"./requestmanager":23}],20:[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 .
+*/
+/** @file eth.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+var utils = require('../utils/utils');
+var Property = require('./property');
+
+/// @returns an array of objects describing web3.eth api methods
+var methods = [
+];
+
+/// @returns an array of objects describing web3.eth api properties
+var properties = [
+ new Property({
+ name: 'listening',
+ getter: 'net_listening'
+ }),
+ new Property({
+ name: 'peerCount',
+ getter: 'net_peerCount',
+ outputFormatter: utils.toDecimal
+ })
+];
+
+
+module.exports = {
+ methods: methods,
+ properties: properties
+};
+
+
+},{"../utils/utils":7,"./property":21}],21:[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 .
+*/
+/**
+ * @file property.js
+ * @author Fabian Vogelsteller
+ * @author Marek Kotewicz
+ * @date 2015
+ */
+
+var RequestManager = require('./requestmanager');
+
+var Property = function (options) {
+ this.name = options.name;
+ this.getter = options.getter;
+ this.setter = options.setter;
+ this.outputFormatter = options.outputFormatter;
+ this.inputFormatter = options.inputFormatter;
+};
+
+/**
+ * Should be called to format input args of method
+ *
+ * @method formatInput
+ * @param {Array}
+ * @return {Array}
+ */
+Property.prototype.formatInput = function (arg) {
+ return this.inputFormatter ? this.inputFormatter(arg) : arg;
+};
+
+/**
+ * Should be called to format output(result) of method
+ *
+ * @method formatOutput
+ * @param {Object}
+ * @return {Object}
+ */
+Property.prototype.formatOutput = function (result) {
+ return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;
+};
+
+/**
+ * Should attach function to method
+ *
+ * @method attachToObject
+ * @param {Object}
+ * @param {Function}
+ */
+Property.prototype.attachToObject = function (obj) {
+ var proto = {
+ get: this.get.bind(this),
+ set: this.set.bind(this)
+ };
+
+ var name = this.name.split('.');
+ if (name.length > 1) {
+ obj[name[0]] = obj[name[0]] || {};
+ Object.defineProperty(obj[name[0]], name[1], proto);
+ } else {
+ Object.defineProperty(obj, name[0], proto);
+ }
+};
+
+/**
+ * Should be used to get value of the property
+ *
+ * @method get
+ * @return {Object} value of the property
+ */
+Property.prototype.get = function () {
+ return this.formatOutput(RequestManager.getInstance().send({
+ method: this.getter
+ }));
+};
+
+/**
+ * Should be used to set value of the property
+ *
+ * @method set
+ * @param {Object} new value of the property
+ */
+Property.prototype.set = function (value) {
+ return RequestManager.getInstance().send({
+ method: this.setter,
+ params: [this.formatInput(value)]
+ });
+};
+
+module.exports = Property;
+
+
+},{"./requestmanager":23}],22:[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 .
+*/
+/** @file qtsync.js
+ * @authors:
+ * Marek Kotewicz
+ * Marian Oancea
+ * @date 2014
+ */
+
+var QtSyncProvider = function () {
+};
+
+QtSyncProvider.prototype.send = function (payload) {
+ var result = navigator.qt.callMethod(JSON.stringify(payload));
+ return JSON.parse(result);
+};
+
+module.exports = QtSyncProvider;
+
+
+},{}],23:[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 .
+*/
+/**
+ * @file requestmanager.js
+ * @author Jeffrey Wilcke
+ * @author Marek Kotewicz
+ * @author Marian Oancea
+ * @author Fabian Vogelsteller
+ * @author Gav Wood
+ * @date 2014
+ */
+
+var Jsonrpc = require('./jsonrpc');
+var utils = require('../utils/utils');
+var c = require('../utils/config');
+var errors = require('./errors');
+
+/**
+ * It's responsible for passing messages to providers
+ * It's also responsible for polling the ethereum node for incoming messages
+ * Default poll timeout is 1 second
+ * Singleton
+ */
+var RequestManager = function (provider) {
+ // singleton pattern
+ if (arguments.callee._singletonInstance) {
+ return arguments.callee._singletonInstance;
+ }
+ arguments.callee._singletonInstance = this;
+
+ this.provider = provider;
+ this.polls = [];
+ this.timeout = null;
+ this.poll();
+};
+
+/**
+ * @return {RequestManager} singleton
+ */
+RequestManager.getInstance = function () {
+ var instance = new RequestManager();
+ return instance;
+};
+
+/**
+ * Should be used to synchronously send request
+ *
+ * @method send
+ * @param {Object} data
+ * @return {Object}
+ */
+RequestManager.prototype.send = function (data) {
+ if (!this.provider) {
+ console.error(errors.InvalidProvider);
+ return null;
+ }
+
+ var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);
+ var result = this.provider.send(payload);
+
+ if (!Jsonrpc.getInstance().isValidResponse(result)) {
+ throw errors.InvalidResponse(result);
+ }
+
+ return result.result;
+};
+
+/**
+ * Should be used to asynchronously send request
+ *
+ * @method sendAsync
+ * @param {Object} data
+ * @param {Function} callback
+ */
+RequestManager.prototype.sendAsync = function (data, callback) {
+ if (!this.provider) {
+ return callback(errors.InvalidProvider);
+ }
+
+ var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);
+ this.provider.sendAsync(payload, function (err, result) {
+ if (err) {
+ return callback(err);
+ }
+
+ if (!Jsonrpc.getInstance().isValidResponse(result)) {
+ return callback(errors.InvalidResponse(result));
+ }
+
+ callback(null, result.result);
+ });
+};
+
+/**
+ * Should be used to set provider of request manager
+ *
+ * @method setProvider
+ * @param {Object}
+ */
+RequestManager.prototype.setProvider = function (p) {
+ this.provider = p;
+};
+
+/*jshint maxparams:4 */
+
+/**
+ * Should be used to start polling
+ *
+ * @method startPolling
+ * @param {Object} data
+ * @param {Number} pollId
+ * @param {Function} callback
+ * @param {Function} uninstall
+ *
+ * @todo cleanup number of params
+ */
+RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
+ this.polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
+};
+/*jshint maxparams:3 */
+
+/**
+ * Should be used to stop polling for filter with given id
+ *
+ * @method stopPolling
+ * @param {Number} pollId
+ */
+RequestManager.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);
+ }
+ }
+};
+
+/**
+ * Should be called to reset polling mechanism of request manager
+ *
+ * @method reset
+ */
+RequestManager.prototype.reset = function () {
+ this.polls.forEach(function (poll) {
+ poll.uninstall(poll.id);
+ });
+ this.polls = [];
+
+ if (this.timeout) {
+ clearTimeout(this.timeout);
+ this.timeout = null;
+ }
+ this.poll();
+};
+
+/**
+ * Should be called to poll for changes on filter with given id
+ *
+ * @method poll
+ */
+RequestManager.prototype.poll = function () {
+ this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
+
+ if (!this.polls.length) {
+ return;
+ }
+
+ if (!this.provider) {
+ console.error(errors.InvalidProvider);
+ return;
+ }
+
+ var payload = Jsonrpc.getInstance().toBatchPayload(this.polls.map(function (data) {
+ return data.data;
+ }));
+
+ var self = this;
+ this.provider.sendAsync(payload, function (error, results) {
+ // TODO: console log?
+ if (error) {
+ return;
+ }
+
+ if (!utils.isArray(results)) {
+ throw errors.InvalidResponse(results);
+ }
+
+ results.map(function (result, index) {
+ result.callback = self.polls[index].callback;
+ return result;
+ }).filter(function (result) {
+ var valid = Jsonrpc.getInstance().isValidResponse(result);
+ if (!valid) {
+ result.callback(errors.InvalidResponse(result));
+ }
+ return valid;
+ }).filter(function (result) {
+ return utils.isArray(result.result) && result.result.length > 0;
+ }).forEach(function (result) {
+ result.callback(null, result.result);
+ });
+ });
+};
+
+module.exports = RequestManager;
+
+
+},{"../utils/config":6,"../utils/utils":7,"./errors":12,"./jsonrpc":18}],24:[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 .
+*/
+/** @file shh.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+var Method = require('./method');
+var formatters = require('./formatters');
+
+var post = new Method({
+ name: 'post',
+ call: 'shh_post',
+ params: 1,
+ inputFormatter: formatters.inputPostFormatter
+});
+
+var newIdentity = new Method({
+ name: 'newIdentity',
+ call: 'shh_newIdentity',
+ params: 0
+});
+
+var hasIdentity = new Method({
+ name: 'hasIdentity',
+ call: 'shh_hasIdentity',
+ params: 1
+});
+
+var newGroup = new Method({
+ name: 'newGroup',
+ call: 'shh_newGroup',
+ params: 0
+});
+
+var addToGroup = new Method({
+ name: 'addToGroup',
+ call: 'shh_addToGroup',
+ params: 0
+});
+
+var methods = [
+ post,
+ newIdentity,
+ hasIdentity,
+ newGroup,
+ addToGroup
+];
+
+module.exports = {
+ methods: methods
+};
+
+
+},{"./formatters":16,"./method":19}],25:[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 .
+*/
+/** @file signature.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+var web3 = require('../web3');
+var c = require('../utils/config');
+
+/// @param function name for which we want to get signature
+/// @returns signature of function with given name
+var functionSignatureFromAscii = function (name) {
+ return web3.sha3(web3.fromAscii(name)).slice(0, 2 + c.ETH_SIGNATURE_LENGTH * 2);
+};
+
+/// @param event name for which we want to get signature
+/// @returns signature of event with given name
+var eventSignatureFromAscii = function (name) {
+ return web3.sha3(web3.fromAscii(name));
+};
+
+module.exports = {
+ functionSignatureFromAscii: functionSignatureFromAscii,
+ eventSignatureFromAscii: eventSignatureFromAscii
+};
+
+
+},{"../utils/config":6,"../web3":9}],26:[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 .
+*/
+/** @file watches.js
+ * @authors:
+ * Marek Kotewicz
+ * @date 2015
+ */
+
+var Method = require('./method');
+
+/// @returns an array of objects describing web3.eth.filter api methods
+var eth = function () {
+ var newFilterCall = function (args) {
+ return typeof args[0] === 'string' ? 'eth_newBlockFilter' : 'eth_newFilter';
+ };
+
+ var newFilter = new Method({
+ name: 'newFilter',
+ call: newFilterCall,
+ params: 1
+ });
+
+ var uninstallFilter = new Method({
+ name: 'uninstallFilter',
+ call: 'eth_uninstallFilter',
+ params: 1
+ });
+
+ var getLogs = new Method({
+ name: 'getLogs',
+ call: 'eth_getFilterLogs',
+ params: 1
+ });
+
+ var poll = new Method({
+ name: 'poll',
+ call: 'eth_getFilterChanges',
+ params: 1
+ });
+
+ return [
+ newFilter,
+ uninstallFilter,
+ getLogs,
+ poll
+ ];
+};
+
+/// @returns an array of objects describing web3.shh.watch api methods
+var shh = function () {
+ var newFilter = new Method({
+ name: 'newFilter',
+ call: 'shh_newFilter',
+ params: 1
+ });
+
+ var uninstallFilter = new Method({
+ name: 'uninstallFilter',
+ call: 'shh_uninstallFilter',
+ params: 1
+ });
+
+ var getLogs = new Method({
+ name: 'getLogs',
+ call: 'shh_getMessages',
+ params: 1
+ });
+
+ var poll = new Method({
+ name: 'poll',
+ call: 'shh_getFilterChanges',
+ params: 1
+ });
+
+ return [
+ newFilter,
+ uninstallFilter,
+ getLogs,
+ poll
+ ];
+};
+
+module.exports = {
+ eth: eth,
+ shh: shh
+};
+
+
+},{"./method":19}],"bignumber.js":[function(require,module,exports){
+/*! bignumber.js v2.0.0 https://github.com/MikeMcl/bignumber.js/LICENCE */
+
+;(function (global) {
+ 'use strict';
+
+ /*
+ bignumber.js v2.0.0
+ A JavaScript library for arbitrary-precision arithmetic.
+ https://github.com/MikeMcl/bignumber.js
+ Copyright (c) 2014 Michael Mclaughlin
+ MIT Expat Licence
+ */
+
+ /*********************************** DEFAULTS ************************************/
+
+ /*
+ * The default values below must be integers within the inclusive ranges stated.
+ * Most of these values can be changed at run-time using the BigNumber.config method.
+ */
+
+ /*
+ * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP,
+ * MAX_EXP, and the argument to toExponential, toFixed, toFormat, and toPrecision,
+ * beyond which an exception is thrown (if ERRORS is true).
+ */
+ var MAX = 1E9, // 0 to 1e+9
+
+ // Limit of magnitude of exponent argument to toPower.
+ MAX_POWER = 1E6, // 1 to 1e+6
+
+ // The maximum number of decimal places for operations involving division.
+ DECIMAL_PLACES = 20, // 0 to MAX
+
+ /*
+ * The rounding mode used when rounding to the above decimal places, and when using
+ * toExponential, toFixed, toFormat and toPrecision, and round (default value).
+ * UP 0 Away from zero.
+ * DOWN 1 Towards zero.
+ * CEIL 2 Towards +Infinity.
+ * FLOOR 3 Towards -Infinity.
+ * HALF_UP 4 Towards nearest neighbour. If equidistant, up.
+ * HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
+ * HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
+ * HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
+ * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
+ */
+ ROUNDING_MODE = 4, // 0 to 8
+
+ // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
+
+ // The exponent value at and beneath which toString returns exponential notation.
+ // Number type: -7
+ TO_EXP_NEG = -7, // 0 to -MAX
+
+ // The exponent value at and above which toString returns exponential notation.
+ // Number type: 21
+ TO_EXP_POS = 21, // 0 to MAX
+
+ // RANGE : [MIN_EXP, MAX_EXP]
+
+ // The minimum exponent value, beneath which underflow to zero occurs.
+ // Number type: -324 (5e-324)
+ MIN_EXP = -MAX, // -1 to -MAX
+
+ // The maximum exponent value, above which overflow to Infinity occurs.
+ // Number type: 308 (1.7976931348623157e+308)
+ MAX_EXP = MAX, // 1 to MAX
+
+ // Whether BigNumber Errors are ever thrown.
+ // CHANGE parseInt to parseFloat if changing ERRORS to false.
+ ERRORS = true, // true or false
+ parse = parseInt, // parseInt or parseFloat
+
+ // Format specification for the BigNumber.prototype.toFormat method.
+ FORMAT = {
+ decimalSeparator: '.',
+ groupSeparator: ',',
+ groupSize: 3,
+ secondaryGroupSize: 0,
+ fractionGroupSeparator: '\xA0', // non-breaking space
+ fractionGroupSize: 0
+ },
+
+ /***********************************************************************************/
+
+ P = BigNumber.prototype,
+ DIGITS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
+ outOfRange,
+ id = 0,
+ mathfloor = Math.floor,
+ isValid = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
+ trim = String.prototype.trim || function () {return this.replace(/^\s+|\s+$/g, '')},
+ BASE = 1e14,
+ LOG_BASE = 14,
+ SQRT_BASE = 1e7,
+ POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
+ ONE = new BigNumber(1);
+
+
+ // CONSTRUCTOR
+
+
+ /*
+ * The exported function.
+ * Create and return a new instance of a BigNumber object.
+ *
+ * v {number|string|BigNumber} A numeric value.
+ * [b] {number} The base of v. Integer, 2 to 64 inclusive.
+ */
+ function BigNumber( n, b ) {
+ var d, e, i, isNum, str, valid,
+ x = this;
+
+ // Enable constructor usage without new.
+ if ( !( x instanceof BigNumber ) ) return new BigNumber( n, b );
+
+ // Duplicate.
+ if ( n instanceof BigNumber ) {
+
+ if ( b == null ) {
+ id = 0;
+ x['s'] = n['s'];
+ x['e'] = n['e'];
+ x['c'] = ( n = n['c'] ) ? n.slice() : n;
+ return;
+ }
+ n += '';
+ } else if ( isNum = ( str = typeof n ) == 'number' ) {
+
+ // Fast path for integers.
+ if ( b == null && n === ~~n ) {
+ x['s'] = 1 / n < 0 ? ( n = -n, -1 ) : 1;
+ for ( e = id = 0, i = n; i >= 10; i /= 10, e++ );
+ x['e'] = e;
+ x['c'] = [n];
+ return;
+ }
+
+ // Minus zero?
+ n = n === 0 && 1 / n < 0 ? '-0' : n + '';
+ } else if ( str != 'string' ) {
+ n += '';
+ }
+ str = n;
+
+ if ( b == null && isValid.test(str) ) {
+
+ // Determine sign.
+ x['s'] = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
+
+ // Either str is not a valid BigNumber or a base has been specified.
+ } else {
+
+ // Enable exponential notation to be used with base 10 argument.
+ // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
+ if ( b == 10 ) {
+ x = new BigNumber(str);
+ return rnd( x, DECIMAL_PLACES + x['e'] + 1, ROUNDING_MODE );
+ }
+ str = trim.call(str).replace( /^\+(?!-)/, '' );
+ x['s'] = str.charCodeAt(0) === 45 ? ( str = str.replace( /^-(?!-)/, '' ), -1 ) : 1;
+
+ if ( b != null ) {
+
+ if ( ( b == ~~b || !ERRORS ) && !( outOfRange = !( b >= 2 && b < 65 ) ) ) {
+ d = '[' + DIGITS.slice( 0, b = b | 0 ) + ']+';
+
+ // Before non-decimal number validity test and base conversion
+ // remove the `.` from e.g. '1.', and replace e.g. '.1' with '0.1'.
+ str = str.replace( /\.$/, '' ).replace( /^\./, '0.' );
+
+ // Any number in exponential form will fail due to the e+/-.
+ if ( valid = new RegExp( '^' + d + '(?:\\.' + d + ')?$',
+ b < 37 ? 'i' : '' ).test(str) ) {
+
+ if (isNum) {
+
+ if ( str.replace( /^0\.0*|\./, '' ).length > 15 ) {
+
+ // 'new BigNumber() number type has more than 15 significant digits: {n}'
+ ifExceptionsThrow( n, 0 );
+ }
+
+ // Prevent later check for length on converted number.
+ isNum = !isNum;
+ }
+ str = convertBase( str, 10, b, x['s'] );
+ } else if ( str != 'Infinity' && str != 'NaN' ) {
+
+ // 'new BigNumber() not a base {b} number: {str}'
+ ifExceptionsThrow( n, 1, b );
+ n = 'NaN';
+ }
+ } else {
+
+ // 'new BigNumber() base not an integer: {b}'
+ // 'new BigNumber() base out of range: {b}'
+ ifExceptionsThrow( b, 2 );
+
+ // Ignore base.
+ valid = isValid.test(str);
+ }
+ } else {
+ valid = isValid.test(str);
+ }
+
+ if ( !valid ) {
+
+ // Infinity/NaN
+ x['c'] = x['e'] = null;
+
+ // NaN
+ if ( str != 'Infinity' ) {
+
+ // No exception on NaN.
+ // 'new BigNumber() not a number: {n}'
+ if ( str != 'NaN' ) ifExceptionsThrow( n, 3 );
+ x['s'] = null;
+ }
+ id = 0;
+
+ return;
+ }
+ }
+
+ // Decimal point?
+ if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );
+
+ // Exponential form?
+ if ( ( i = str.search( /e/i ) ) > 0 ) {
+
+ // Determine exponent.
+ if ( e < 0 ) e = i;
+ e += +str.slice( i + 1 );
+ str = str.substring( 0, i );
+ } else if ( e < 0 ) {
+
+ // Integer.
+ e = str.length;
+ }
+
+ // Determine leading zeros.
+ for ( i = 0; str.charCodeAt(i) === 48; i++ );
+
+ // Determine trailing zeros.
+ for ( b = str.length; str.charCodeAt(--b) === 48; );
+ str = str.slice( i, b + 1 );
+
+ if (str) {
+ b = str.length;
+
+ // Disallow numbers with over 15 significant digits if number type.
+ // 'new BigNumber() number type has more than 15 significant digits: {n}'
+ if ( isNum && b > 15 ) ifExceptionsThrow( n, 0 );
+ e = e - i - 1;
+
+ // Overflow?
+ if ( e > MAX_EXP ) {
+
+ // Infinity.
+ x['c'] = x['e'] = null;
+
+ // Underflow?
+ } else if ( e < MIN_EXP ) {
+
+ // Zero.
+ x['c'] = [ x['e'] = 0 ];
+ } else {
+ x['e'] = e;
+ x['c'] = [];
+
+ // Transform base
+
+ // e is the base 10 exponent.
+ // i is where to slice str to get the first element of the coefficient array.
+ i = ( e + 1 ) % LOG_BASE;
+ if ( e < 0 ) i += LOG_BASE;
+
+ // b is str.length.
+ if ( i < b ) {
+ if (i) x['c'].push( +str.slice( 0, i ) );
+ for ( b -= LOG_BASE; i < b; x['c'].push( +str.slice( i, i += LOG_BASE ) ) );
+ str = str.slice(i);
+ i = LOG_BASE - str.length;
+ } else {
+ i -= b;
+ }
+
+ for ( ; i--; str += '0' );
+ x['c'].push( +str );
+ }
+ } else {
+
+ // Zero.
+ x['c'] = [ x['e'] = 0 ];
+ }
+ id = 0;
+ }
+
+
+ // CONSTRUCTOR PROPERTIES/METHODS
+
+
+ BigNumber['ROUND_UP'] = 0;
+ BigNumber['ROUND_DOWN'] = 1;
+ BigNumber['ROUND_CEIL'] = 2;
+ BigNumber['ROUND_FLOOR'] = 3;
+ BigNumber['ROUND_HALF_UP'] = 4;
+ BigNumber['ROUND_HALF_DOWN'] = 5;
+ BigNumber['ROUND_HALF_EVEN'] = 6;
+ BigNumber['ROUND_HALF_CEIL'] = 7;
+ BigNumber['ROUND_HALF_FLOOR'] = 8;
+
+
+ /*
+ * Configure infrequently-changing library-wide settings.
+ *
+ * Accept an object or an argument list, with one or many of the following properties or
+ * parameters respectively:
+ * [ DECIMAL_PLACES [, ROUNDING_MODE [, EXPONENTIAL_AT [, RANGE [, ERRORS [, FORMAT ]]]]]]
+ *
+ * DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
+ * ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
+ * EXPONENTIAL_AT {number|number[]} Integer, -MAX to MAX inclusive or
+ * [ integer -MAX to 0 incl., 0 to MAX incl. ].
+ * RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
+ * [ integer -MAX to -1 incl., integer 1 to MAX incl. ].
+ * ERRORS {boolean|number} true, false, 1 or 0.
+ * FORMAT {object} See BigNumber.prototype.toFormat.
+ * decimalSeparator {string}
+ * groupSeparator {string}
+ * groupSize {number}
+ * secondaryGroupSize {number}
+ * fractionGroupSeparator {string}
+ * fractionGroupSize {number}
+ *
+ * The validity of the values assigned to the above FORMAT object properties is not checked.
+ *
+ * E.g.
+ * BigNumber.config(20, 4) is equivalent to
+ * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
+ *
+ * Ignore properties/parameters set to null or undefined.
+ * Return an object with the properties current values.
+ */
+ BigNumber['config'] = function () {
+ var v, p,
+ i = 0,
+ r = {},
+ a = arguments,
+ o = a[0],
+ c = 'config',
+ inRange = function ( n, lo, hi ) {
+ return !( ( outOfRange = n < lo || n > hi ) || parse(n) != n && n !== 0 );
+ },
+ has = o && typeof o == 'object'
+ ? function () {if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null}
+ : function () {if ( a.length > i ) return ( v = a[i++] ) != null};
+
+ // [DECIMAL_PLACES] {number} Integer, 0 to MAX inclusive.
+ if ( has( p = 'DECIMAL_PLACES' ) ) {
+
+ if ( inRange( v, 0, MAX ) ) {
+ DECIMAL_PLACES = v | 0;
+ } else {
+
+ // 'config() DECIMAL_PLACES not an integer: {v}'
+ // 'config() DECIMAL_PLACES out of range: {v}'
+ ifExceptionsThrow( v, p, c );
+ }
+ }
+ r[p] = DECIMAL_PLACES;
+
+ // [ROUNDING_MODE] {number} Integer, 0 to 8 inclusive.
+ if ( has( p = 'ROUNDING_MODE' ) ) {
+
+ if ( inRange( v, 0, 8 ) ) {
+ ROUNDING_MODE = v | 0;
+ } else {
+
+ // 'config() ROUNDING_MODE not an integer: {v}'
+ // 'config() ROUNDING_MODE out of range: {v}'
+ ifExceptionsThrow( v, p, c );
+ }
+ }
+ r[p] = ROUNDING_MODE;
+
+ // [EXPONENTIAL_AT] {number|number[]}
+ // Integer, -MAX to MAX inclusive or [ integer -MAX to 0 inclusive, 0 to MAX inclusive ].
+ if ( has( p = 'EXPONENTIAL_AT' ) ) {
+
+ if ( inRange( v, -MAX, MAX ) ) {
+ TO_EXP_NEG = -( TO_EXP_POS = ~~( v < 0 ? -v : +v ) );
+ } else if ( !outOfRange && v && inRange( v[0], -MAX, 0 ) && inRange( v[1], 0, MAX ) ) {
+ TO_EXP_NEG = ~~v[0];
+ TO_EXP_POS = ~~v[1];
+ } else {
+
+ // 'config() EXPONENTIAL_AT not an integer or not [integer, integer]: {v}'
+ // 'config() EXPONENTIAL_AT out of range or not [negative, positive: {v}'
+ ifExceptionsThrow( v, p, c, 1 );
+ }
+ }
+ r[p] = [ TO_EXP_NEG, TO_EXP_POS ];
+
+ // [RANGE][ {number|number[]} Non-zero integer, -MAX to MAX inclusive or
+ // [ integer -MAX to -1 inclusive, integer 1 to MAX inclusive ].
+ if ( has( p = 'RANGE' ) ) {
+
+ if ( inRange( v, -MAX, MAX ) && ~~v ) {
+ MIN_EXP = -( MAX_EXP = ~~( v < 0 ? -v : +v ) );
+ } else if ( !outOfRange && v && inRange( v[0], -MAX, -1 ) && inRange( v[1], 1, MAX ) ) {
+ MIN_EXP = ~~v[0];
+ MAX_EXP = ~~v[1];
+ } else {
+
+ // 'config() RANGE not a non-zero integer or not [integer, integer]: {v}'
+ // 'config() RANGE out of range or not [negative, positive: {v}'
+ ifExceptionsThrow( v, p, c, 1, 1 );
+ }
+ }
+ r[p] = [ MIN_EXP, MAX_EXP ];
+
+ // [ERRORS] {boolean|number} true, false, 1 or 0.
+ if ( has( p = 'ERRORS' ) ) {
+
+ if ( v === !!v || v === 1 || v === 0 ) {
+ outOfRange = id = 0;
+ parse = ( ERRORS = !!v ) ? parseInt : parseFloat;
+ } else {
+
+ // 'config() ERRORS not a boolean or binary digit: {v}'
+ ifExceptionsThrow( v, p, c, 0, 0, 1 );
+ }
+ }
+ r[p] = ERRORS;
+
+ // [FORMAT] {object}
+ if ( has( p = 'FORMAT' ) ) {
+
+ if ( typeof v == 'object' ) {
+ FORMAT = v;
+ } else if (ERRORS) {
+
+ // 'config() FORMAT not an object: {v}'
+ r = new Error( c + '() ' + p + ' not an object: ' + v );
+ r['name'] = 'BigNumber Error';
+ throw r;
+ }
+ }
+ r[p] = FORMAT;
+
+ return r;
+ };
+
+
+ // PRIVATE FUNCTIONS
+
+
+ /*
+ * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
+ * Called by minus, plus and times.
+ */
+ function normalise( bn, c, e ) {
+ var i = 1,
+ j = c.length;
+
+ // Remove trailing zeros.
+ for ( ; !c[--j]; c.pop() );
+
+ // Calculate the base 10 exponent. First get the number of digits of c[0].
+ for ( j = c[0]; j >= 10; j /= 10, i++ );
+
+ // Overflow?
+ if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {
+
+ // Infinity.
+ bn['c'] = bn['e'] = null;
+
+ // Underflow?
+ } else if ( e < MIN_EXP ) {
+
+ // Zero.
+ bn['c'] = [ bn['e'] = 0 ];
+ } else {
+ bn['e'] = e;
+ bn['c'] = c;
+ }
+
+ return bn;
+ }
+
+
+ /*
+ * Returns the coefficient array as a string of base 10 digits.
+ */
+ function coefficientToString(a) {
+ var s, z,
+ i = 1,
+ j = a.length,
+ r = a[0] + '';
+
+ for ( ; i < j; ) {
+ s = a[i++] + '';
+ z = LOG_BASE - s.length;
+ for ( ; z--; s = '0' + s );
+ r += s;
+ }
+
+ // '0'
+ for ( j = r.length; r.charCodeAt(--j) === 48; );
+
+ return r.slice( 0, j + 1 || 1 );
+ }
+
+
+ /*
+ * Convert string of baseIn to an array of numbers of baseOut.
+ * Eg. convertBase('255', 10, 16) returns [15, 15].
+ * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
+ */
+ function toBaseOut( str, baseIn, baseOut ) {
+ var j,
+ arr = [0],
+ arrL,
+ i = 0,
+ strL = str.length;
+
+ for ( ; i < strL; ) {
+ for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );
+ arr[ j = 0 ] += DIGITS.indexOf( str.charAt( i++ ) );
+
+ for ( ; j < arr.length; j++ ) {
+
+ if ( arr[j] > baseOut - 1 ) {
+ if ( arr[j + 1] == null ) arr[j + 1] = 0;
+ arr[j + 1] += arr[j] / baseOut | 0;
+ arr[j] %= baseOut;
+ }
+ }
+ }
+
+ return arr.reverse();
+ }
+
+ /*
+ * Convert a numeric string of baseIn to a numeric string of baseOut.
+ */
+ function convertBase( str, baseOut, baseIn, sign ) {
+ var d, e, j, r, x, xc, y,
+ i = str.indexOf( '.' ),
+ rm = ROUNDING_MODE;
+
+ if ( baseIn < 37 ) str = str.toLowerCase();
+
+ // Non-integer.
+ if ( i >= 0 ) {
+ str = str.replace( '.', '' );
+ y = new BigNumber(baseIn);
+ x = y['pow']( str.length - i );
+
+ // Convert str as if an integer, then restore the fraction part by dividing the result
+ // by its base raised to a power. Use toFixed to avoid possible exponential notation.
+ y['c'] = toBaseOut( x.toFixed(), 10, baseOut );
+ y['e'] = y['c'].length;
+ }
+
+ // Convert the number as integer.
+ xc = toBaseOut( str, baseIn, baseOut );
+ e = j = xc.length;
+
+ // Remove trailing zeros.
+ for ( ; xc[--j] == 0; xc.pop() );
+ if ( !xc[0] ) return '0';
+
+ if ( i < 0 ) {
+ --e;
+ } else {
+ x['c'] = xc;
+ x['e'] = e;
+ // sign is needed for correct rounding.
+ x['s'] = sign;
+ x = div( x, y, DECIMAL_PLACES, rm, baseOut );
+ xc = x['c'];
+ r = x['r'];
+ e = x['e'];
+ }
+ d = e + DECIMAL_PLACES + 1;
+
+ // The rounding digit, i.e. the digit after the digit that may be rounded up.
+ i = xc[d];
+ j = baseOut / 2;
+ r = r || d < 0 || xc[d + 1] != null;
+
+ r = rm < 4
+ ? ( i != null || r ) && ( rm == 0 || rm == ( x['s'] < 0 ? 3 : 2 ) )
+ : i > j || i == j &&
+ ( rm == 4 || r || rm == 6 && xc[d - 1] & 1 || rm == ( x['s'] < 0 ? 8 : 7 ) );
+
+ if ( d < 1 || !xc[0] ) {
+ xc.length = 1;
+ j = 0;
+
+ if (r) {
+
+ // 1, 0.1, 0.01, 0.001, 0.0001 etc.
+ xc[0] = 1;
+ e = -DECIMAL_PLACES;
+ } else {
+
+ // Zero.
+ e = xc[0] = 0;
+ }
+ } else {
+ xc.length = d;
+
+ if (r) {
+
+ // Rounding up may mean the previous digit has to be rounded up and so on.
+ for ( --baseOut; ++xc[--d] > baseOut; ) {
+ xc[d] = 0;
+
+ if ( !d ) {
+ ++e;
+ xc.unshift(1);
+ }
+ }
+ }
+
+ // Determine trailing zeros.
+ for ( j = xc.length; !xc[--j]; );
+ }
+
+ // E.g. [4, 11, 15] becomes 4bf.
+ for ( i = 0, str = ''; i <= j; str += DIGITS.charAt( xc[i++] ) );
+
+ // Negative exponent?
+ if ( e < 0 ) {
+
+ // Prepend zeros.
+ for ( ; ++e; str = '0' + str );
+ str = '0.' + str;
+
+ // Positive exponent?
+ } else {
+ i = str.length;
+
+ // Append zeros.
+ if ( ++e > i ) {
+ for ( e -= i; e-- ; str += '0' );
+ } else if ( e < i ) {
+ str = str.slice( 0, e ) + '.' + str.slice(e);
+ }
+ }
+
+ // No negative numbers: the caller will add the sign.
+ return str;
+ }
+
+
+ /*
+ * Perform division in the specified base. Called by div and convertBase.
+ */
+ var div = ( function () {
+
+ // Assumes non-zero x and k.
+ function multiply( x, k, base ) {
+ var m, temp, xlo, xhi,
+ carry = 0,
+ i = x.length,
+ klo = k % SQRT_BASE,
+ khi = k / SQRT_BASE | 0;
+
+ for ( x = x.slice(); i--; ) {
+ xlo = x[i] % SQRT_BASE;
+ xhi = x[i] / SQRT_BASE | 0;
+ m = khi * xlo + xhi * klo;
+ temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;
+ carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;
+ x[i] = temp % base;
+ }
+ if (carry) x.unshift(carry);
+
+ return x;
+ }
+
+ function compare( a, b, aL, bL ) {
+ var i, cmp;
+
+ if ( aL != bL ) {
+ cmp = aL > bL ? 1 : -1;
+ } else {
+
+ for ( i = cmp = 0; i < aL; i++ ) {
+
+ if ( a[i] != b[i] ) {
+ cmp = a[i] > b[i] ? 1 : -1;
+ break;
+ }
+ }
+ }
+ return cmp;
+ }
+
+ function subtract( a, b, aL, base ) {
+ var i = 0;
+
+ // Subtract b from a.
+ for ( ; aL--; ) {
+ a[aL] -= i;
+ i = a[aL] < b[aL] ? 1 : 0;
+ a[aL] = i * base + a[aL] - b[aL];
+ }
+
+ // Remove leading zeros.
+ for ( ; !a[0] && a.length > 1; a.shift() );
+ }
+
+ // x: dividend, y: divisor.
+ return function ( x, y, dp, rm, base ) {
+ var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
+ yL, yz,
+ s = x['s'] == y['s'] ? 1 : -1,
+ xc = x['c'],
+ yc = y['c'];
+
+ // Either NaN, Infinity or 0?
+ if ( !xc || !xc[0] || !yc || !yc[0] ) {
+
+ return new BigNumber(
+
+ // Return NaN if either NaN, or both Infinity or 0.
+ !x['s'] || !y['s'] || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :
+
+ // Return +-0 if x is 0 or y is +-Infinity, or return +-Infinity as y is 0.
+ xc && xc[0] == 0 || !yc ? s * 0 : s / 0
+ );
+ }
+
+ q = new BigNumber(s);
+ qc = q['c'] = [];
+ e = x['e'] - y['e'];
+ s = dp + e + 1;
+
+ if ( !base ) {
+ base = BASE;
+
+ //e = mathfloor( x['e'] / LOG_BASE ) - mathfloor( y['e'] / LOG_BASE );
+ e = ( xL = x['e'] / LOG_BASE, i = xL | 0, xL > 0 || xL === i ? i : i - 1 ) -
+ ( yL = y['e'] / LOG_BASE, i = yL | 0, yL > 0 || yL === i ? i : i - 1 );
+
+ s = s / LOG_BASE | 0;
+ }
+
+ // Result exponent may be one less then the current value of e.
+ // The coefficients of the BigNumbers from convertBase may have trailing zeros.
+ for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );
+ if ( yc[i] > ( xc[i] || 0 ) ) e--;
+
+ if ( s < 0 ) {
+ qc.push(1);
+ more = true;
+ } else {
+ xL = xc.length;
+ yL = yc.length;
+ i = 0;
+ s += 2;
+
+ /*
+ // TODO: fast path division when divisor < base
+ if ( yL == 1 ) {
+ n = 0;
+ yc = yc[0];
+ s++;
+ // n is the carry.
+ for ( ; ( i < xL || n ) && s--; i++ ) {
+ // Can't use this, it will overflow 2^53.
+ var t = n * base + ( xc[i] || 0 );
+ qc[i] = mathfloor( t / yc );
+ n = t % yc;
+ }
+ more = n || i < xL;
+
+ // divisor >= base
+ } else {
+ */
+ // Normalise xc and yc so highest order digit of yc is >= base/2
+
+ n = mathfloor( base / ( yc[0] + 1 ) );
+
+ if ( n > 1 ) {
+ yc = multiply( yc, n, base );
+ xc = multiply( xc, n, base );
+ yL = yc.length;
+ xL = xc.length;
+ }
+
+ xi = yL;
+ rem = xc.slice( 0, yL );
+ remL = rem.length;
+
+ // Add zeros to make remainder as long as divisor.
+ for ( ; remL < yL; rem[remL++] = 0 );
+ yz = yc.slice();
+ yz.unshift(0);
+ yc0 = yc[0];
+ if ( yc[1] >= base / 2 ) yc0++;
+
+ do {
+ n = 0;
+
+ // Compare divisor and remainder.
+ cmp = compare( yc, rem, yL, remL );
+
+ // If divisor < remainder.
+ if ( cmp < 0 ) {
+
+ // Calculate trial digit, n.
+
+ rem0 = rem[0];
+ if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );
+
+ // n is how many times the divisor goes into the current remainder.
+ n = mathfloor( rem0 / yc0 );
+
+
+ // Algorithm:
+ // 1. product = divisor * trial digit (n)
+ // 2. if product > remainder: product -= divisor, n--
+ // 3. remainder -= product
+ // 4. if product was < remainder at 2:
+ // 5. compare new remainder and divisor
+ // 6. If remainder > divisor: remainder -= divisor, n++
+
+ if ( n > 1 ) {
+ if ( n >= base ) n = base - 1;
+
+ // product = divisor * trial digit.
+ prod = multiply( yc, n, base );
+ prodL = prod.length;
+ remL = rem.length;
+
+ // Compare product and remainder.
+ cmp = compare( prod, rem, prodL, remL );
+
+ // product > remainder.
+ if ( cmp == 1 ) {
+ n--;
+
+ // Subtract divisor from product.
+ subtract( prod, yL < prodL ? yz : yc, prodL, base );
+ }
+ } else {
+
+ // cmp is -1.
+ // If n is 0, there is no need to compare yc and rem again below,
+ // so change cmp to 1 to avoid it.
+ // If n is 1, compare yc and rem again below.
+ if ( n == 0 ) cmp = n = 1;
+ prod = yc.slice();
+ }
+
+ prodL = prod.length;
+ if ( prodL < remL ) prod.unshift(0);
+
+ // Subtract product from remainder.
+ subtract( rem, prod, remL, base );
+
+ // If product was < previous remainder.
+ if ( cmp == -1 ) {
+ remL = rem.length;
+
+ // Compare divisor and new remainder.
+ cmp = compare( yc, rem, yL, remL );
+
+ // If divisor < new remainder, subtract divisor from remainder.
+ if ( cmp < 1 ) {
+ n++;
+
+ // Subtract divisor from remainder.
+ subtract( rem, yL < remL ? yz : yc, remL, base );
+ }
+ }
+ remL = rem.length;
+ } else if ( cmp === 0 ) {
+ n++;
+ rem = [0];
+ } // if cmp === 1, n will be 0
+
+ // Add the next digit, n, to the result array.
+ qc[i++] = n;
+
+ // Update the remainder.
+ if ( cmp && rem[0] ) {
+ rem[remL++] = xc[xi] || 0;
+ } else {
+ rem = [ xc[xi] ];
+ remL = 1;
+ }
+ } while ( ( xi++ < xL || rem[0] != null ) && s-- );
+
+ more = rem[0] != null;
+ //}
+
+ // Leading zero?
+ if ( !qc[0] ) qc.shift();
+ }
+
+ if ( base == BASE ) {
+
+ // To calculate q.e, first get the number of digits of qc[0].
+ for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );
+ rnd( q, dp + ( q['e'] = i + e * LOG_BASE - 1 ) + 1, rm, more );
+
+ // div is being used for base conversion.
+ } else {
+ q['e'] = e;
+ q['r'] = +more;
+ }
+ return q;
+ };
+ })();
+
+
+ /*
+ * Return a string representing the value of BigNumber n in normal or exponential notation
+ * rounded to the specified decimal places or significant digits.
+ *
+ * Called by toString (k: 1), toExponential (k: 1), toFixed (k: undefined), toPrecision (k: 2).
+ * i is the index (with the value in normal notation) of the digit that may be rounded up.
+ * d is the number of digits required including fraction-part trailing zeros.
+ * z is the number of zeros to be appended.
+ */
+ function format( n, i, k ) {
+ var d, str, z,
+ e = ( n = new BigNumber(n) )['e'];
+
+ // i == null when toExponential(no arg), or toString() when x >= toExpPos etc.
+ if ( i == null ) {
+ d = 0;
+ } else {
+ rnd( n, ++i, ROUNDING_MODE );
+
+ // n['e'] may have changed if the value was rounded up.
+ d = k ? i : i + n['e'] - e;
+ e = n['e'];
+ }
+ str = coefficientToString( n['c'] );
+
+ // toPrecision returns exponential notation if the number of significant digits specified
+ // is less than the number of digits necessary to represent the integer part of the value
+ // in normal notation.
+
+ // Exponential notation.
+ if ( k == 1 || k == 2 && ( i <= e || e <= TO_EXP_NEG ) ) {
+
+ // Append zeros?
+ for ( ; str.length < d; str += '0' );
+ if ( str.length > 1 ) str = str.charAt(0) + '.' + str.slice(1);
+ str += ( e < 0 ? 'e' : 'e+' ) + e;
+
+ // Fixed point notation.
+ } else {
+ k = str.length;
+
+ // Negative exponent?
+ if ( e < 0 ) {
+ z = d - k;
+
+ // Prepend zeros.
+ for ( ; ++e; str = '0' + str );
+ str = '0.' + str;
+
+ // Positive exponent?
+ } else {
+
+ if ( ++e > k ) {
+ z = d - e;
+
+ // Append zeros.
+ for ( e -= k; e-- ; str += '0' );
+ if ( z > 0 ) str += '.';
+ } else {
+ z = d - k;
+
+ if ( e < k ) {
+ str = str.slice( 0, e ) + '.' + str.slice(e);
+ } else if ( z > 0 ) {
+ str += '.';
+ }
+ }
+ }
+
+ // Append more zeros?
+ if ( z > 0 ) for ( ; z--; str += '0' );
+ }
+ return n['s'] < 0 && n['c'][0] ? '-' + str : str;
+ }
+
+
+ // Assemble error messages. Throw BigNumber Errors.
+ function ifExceptionsThrow( arg, i, j, isArray, isRange, isErrors) {
+
+ if (ERRORS) {
+ var error,
+ method = ['new BigNumber', 'cmp', 'div', 'eq', 'gt', 'gte', 'lt',
+ 'lte', 'minus', 'mod', 'plus', 'times', 'toFraction', 'divToInt'
+ ][ id ? id < 0 ? -id : id : 1 / id < 0 ? 1 : 0 ] + '()',
+ message = outOfRange ? ' out of range' : ' not a' +
+ ( isRange ? ' non-zero' : 'n' ) + ' integer';
+
+ message = ( [
+ method + ' number type has more than 15 significant digits',
+ method + ' not a base ' + j + ' number',
+ method + ' base' + message,
+ method + ' not a number' ][i] ||
+ j + '() ' + i + ( isErrors
+ ? ' not a boolean or binary digit'
+ : message + ( isArray
+ ? ' or not [' + ( outOfRange
+ ? ' negative, positive'
+ : ' integer, integer' ) + ' ]'
+ : '' ) ) ) + ': ' + arg;
+
+ outOfRange = id = 0;
+ error = new Error(message);
+ error['name'] = 'BigNumber Error';
+ throw error;
+ }
+ }
+
+
+ /*
+ * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
+ */
+ function rnd( x, sd, rm, r ) {
+ var d, i, j, k, n, ni, rd, xc,
+ pows10 = POWS_TEN;
+
+ // if x is not Infinity or NaN...
+ if ( xc = x['c'] ) {
+
+ // rd: the rounding digit, i.e. the digit after the digit that may be rounded up
+ // n: a base 1e14 number, the value of the element of array x.c containing rd
+ // ni: the index of n within x.c
+ // d: the number of digits of n
+ // i: what would be the index of rd within n if all the numbers were 14 digits long
+ // (i.e. they had leading zeros)
+ // j: if > 0, the actual index of rd within n (if < 0, rd is a leading zero)
+ out: {
+
+ // Get the number of digits of the first element of xc.
+ for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );
+ i = sd - d;
+
+ // If the rounding digit is in the first element of xc...
+ if ( i < 0 ) {
+ i += LOG_BASE;
+ j = sd;
+ n = xc[ ni = 0 ];
+
+ // Get the rounding digit at index j of n.
+ rd = n / pows10[ d - j - 1 ] % 10 | 0;
+ } else {
+ ni = Math.ceil( ( i + 1 ) / LOG_BASE );
+
+ if ( ni >= xc.length ) {
+
+ if (r) {
+
+ // Needed by sqrt.
+ for ( ; xc.length <= ni; xc.push(0) );
+ n = rd = 0;
+ d = 1;
+ i %= LOG_BASE;
+ j = i - LOG_BASE + 1;
+ } else {
+ break out;
+ }
+ } else {
+ n = k = xc[ni];
+
+ // Get the number of digits of n.
+ for ( d = 1; k >= 10; k /= 10, d++ );
+
+ // Get the index of rd within n.
+ i %= LOG_BASE;
+
+ // Get the index of rd within n, adjusted for leading zeros.
+ // The number of leading zeros of n is given by LOG_BASE - d.
+ j = i - LOG_BASE + d;
+
+ // Get the rounding digit at index j of n.
+ rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;
+ }
+ }
+
+ r = r || sd < 0 ||
+
+ // Are there any non-zero digits after the rounding digit?
+ // The expression n % pows10[ d - j - 1 ] returns all the digits of n to the right
+ // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
+ xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );
+
+ r = rm < 4
+ ? ( rd || r ) && ( rm == 0 || rm == ( x['s'] < 0 ? 3 : 2 ) )
+ : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&
+
+ // Check whether the digit to the left of the rounding digit is odd.
+ ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||
+ rm == ( x['s'] < 0 ? 8 : 7 ) );
+
+ if ( sd < 1 || !xc[0] ) {
+ xc.length = 0;
+
+ if (r) {
+
+ // Convert sd to decimal places.
+ sd -= x['e'] + 1;
+
+ // 1, 0.1, 0.01, 0.001, 0.0001 etc.
+ xc[0] = pows10[ sd % LOG_BASE ];
+ x['e'] = -sd || 0;
+ } else {
+
+ // Zero.
+ xc[0] = x['e'] = 0;
+ }
+
+ return x;
+ }
+
+ // Remove excess digits.
+ if ( i == 0 ) {
+ xc.length = ni;
+ k = 1;
+ ni--;
+ } else {
+ xc.length = ni + 1;
+ k = pows10[ LOG_BASE - i ];
+
+ // E.g. 56700 becomes 56000 if 7 is the rounding digit.
+ // j > 0 means i > number of leading zeros of n.
+ xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;
+ }
+
+ // Round up?
+ if (r) {
+
+ for ( ; ; ) {
+
+ // If the digit to be rounded up is in the first element of xc...
+ if ( ni == 0 ) {
+
+ // i will be the length of xc[0] before k is added.
+ for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );
+ j = xc[0] += k;
+ for ( k = 1; j >= 10; j /= 10, k++ );
+
+ // if i != k the length has increased.
+ if ( i != k ) {
+ x['e']++;
+ if ( xc[0] == BASE ) xc[0] = 1;
+ }
+ break;
+ } else {
+ xc[ni] += k;
+ if ( xc[ni] != BASE ) break;
+ xc[ni--] = 0;
+ k = 1;
+ }
+ }
+ }
+
+ // Remove trailing zeros.
+ for ( i = xc.length; xc[--i] === 0; xc.pop() );
+ }
+
+ // Overflow? Infinity.
+ if ( x['e'] > MAX_EXP ) {
+ x['c'] = x['e'] = null;
+
+ // Underflow? Zero.
+ } else if ( x['e'] < MIN_EXP ) {
+ x['c'] = [ x['e'] = 0 ];
+ }
+ }
+
+ return x;
+ }
+
+
+ // PROTOTYPE/INSTANCE METHODS
+
+
+ /*
+ * Return a new BigNumber whose value is the absolute value of this BigNumber.
+ */
+ P['absoluteValue'] = P['abs'] = function () {
+ var x = new BigNumber(this);
+ if ( x['s'] < 0 ) x['s'] = 1;
+ return x;
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole number
+ * in the direction of Infinity.
+ */
+ P['ceil'] = function () {
+ return rnd( new BigNumber(this), this['e'] + 1, 2 );
+ };
+
+
+ /*
+ * Return
+ * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
+ * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
+ * 0 if they have the same value,
+ * or null if the value of either is NaN.
+ */
+ P['comparedTo'] = P['cmp'] = function ( y, b ) {
+ var a,
+ x = this,
+ xc = x['c'],
+ yc = ( id = -id, y = new BigNumber( y, b ) )['c'],
+ i = x['s'],
+ j = y['s'],
+ k = x['e'],
+ l = y['e'];
+
+ // Either NaN?
+ if ( !i || !j ) return null;
+
+ a = xc && !xc[0];
+ b = yc && !yc[0];
+
+ // Either zero?
+ if ( a || b ) return a ? b ? 0 : -j : i;
+
+ // Signs differ?
+ if ( i != j ) return i;
+
+ a = i < 0;
+ b = k == l;
+
+ // Either Infinity?
+ if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;
+
+ // Compare exponents.
+ if ( !b ) return k > l ^ a ? 1 : -1;
+ i = -1;
+ j = ( k = xc.length ) < ( l = yc.length ) ? k : l;
+
+ // Compare digit by digit.
+ for ( ; ++i < j; ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;
+
+ // Compare lengths.
+ return k == l ? 0 : k > l ^ a ? 1 : -1;
+ };
+
+
+ /*
+ * Return the number of decimal places of the value of this BigNumber, or null if the value of
+ * this BigNumber is +-Infinity or NaN.
+ */
+ P['decimalPlaces'] = P['dp'] = function () {
+ var n, v,
+ c = this['c'];
+
+ if ( !c ) return null;
+ n = ( ( v = c.length - 1 ) - mathfloor( this['e'] / LOG_BASE ) ) * LOG_BASE;
+
+ // Subtract the number of trailing zeros of the last number.
+ if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );
+ if ( n < 0 ) n = 0;
+
+ return n;
+ };
+
+
+ /*
+ * n / 0 = I
+ * n / N = N
+ * n / I = 0
+ * 0 / n = 0
+ * 0 / 0 = N
+ * 0 / N = N
+ * 0 / I = 0
+ * N / n = N
+ * N / 0 = N
+ * N / N = N
+ * N / I = N
+ * I / n = I
+ * I / 0 = I
+ * I / N = N
+ * I / I = N
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
+ * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
+ */
+ P['dividedBy'] = P['div'] = function ( y, b ) {
+ id = 2;
+ return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the integer part of dividing the value of this
+ * BigNumber by the value of BigNumber(y, b).
+ */
+ P['dividedToIntegerBy'] = P['divToInt'] = function ( y, b ) {
+ id = 13;
+ return div( this, new BigNumber( y, b ), 0, 1 );
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is equal to the value of BigNumber(n, b),
+ * otherwise returns false.
+ */
+ P['equals'] = P['eq'] = function ( n, b ) {
+ id = 3;
+ return this['cmp']( n, b ) === 0;
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole number
+ * in the direction of -Infinity.
+ */
+ P['floor'] = function () {
+ return rnd( new BigNumber(this), this['e'] + 1, 3 );
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is greater than the value of BigNumber(n, b),
+ * otherwise returns false.
+ */
+ P['greaterThan'] = P['gt'] = function ( n, b ) {
+ id = 4;
+ return this['cmp']( n, b ) > 0;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is greater than or equal to the value of
+ * BigNumber(n, b), otherwise returns false.
+ */
+ P['greaterThanOrEqualTo'] = P['gte'] = function ( n, b ) {
+ id = 5;
+ return ( b = this['cmp']( n, b ) ) == 1 || b === 0;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is a finite number, otherwise returns false.
+ */
+ P['isFinite'] = function () {
+ return !!this['c'];
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is an integer, otherwise return false.
+ */
+ P['isInteger'] = P['isInt'] = function () {
+ return !!this['c'] && mathfloor( this['e'] / LOG_BASE ) > this['c'].length - 2;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is NaN, otherwise returns false.
+ */
+ P['isNaN'] = function () {
+ return !this['s'];
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is negative, otherwise returns false.
+ */
+ P['isNegative'] = P['isNeg'] = function () {
+ return this['s'] < 0;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.
+ */
+ P['isZero'] = function () {
+ return !!this['c'] && this['c'][0] == 0;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is less than the value of BigNumber(n, b),
+ * otherwise returns false.
+ */
+ P['lessThan'] = P['lt'] = function ( n, b ) {
+ id = 6;
+ return this['cmp']( n, b ) < 0;
+ };
+
+
+ /*
+ * Return true if the value of this BigNumber is less than or equal to the value of
+ * BigNumber(n, b), otherwise returns false.
+ */
+ P['lessThanOrEqualTo'] = P['lte'] = function ( n, b ) {
+ id = 7;
+ return ( b = this['cmp']( n, b ) ) == -1 || b === 0;
+ };
+
+
+ /*
+ * n - 0 = n
+ * n - N = N
+ * n - I = -I
+ * 0 - n = -n
+ * 0 - 0 = 0
+ * 0 - N = N
+ * 0 - I = -I
+ * N - n = N
+ * N - 0 = N
+ * N - N = N
+ * N - I = N
+ * I - n = I
+ * I - 0 = I
+ * I - N = N
+ * I - I = N
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber minus the value of
+ * BigNumber(y, b).
+ */
+ P['minus'] = function ( y, b ) {
+ var i, j, t, xLTy,
+ x = this,
+ a = x['s'];
+
+ id = 8;
+ y = new BigNumber( y, b );
+ b = y['s'];
+
+ // Either NaN?
+ if ( !a || !b ) return new BigNumber(NaN);
+
+ // Signs differ?
+ if ( a != b ) {
+ y['s'] = -b;
+ return x['plus'](y);
+ }
+
+ var xe = x['e'] / LOG_BASE,
+ ye = y['e'] / LOG_BASE,
+ xc = x['c'],
+ yc = y['c'];
+
+ if ( !xe || !ye ) {
+
+ // Either Infinity?
+ if ( !xc || !yc ) return xc ? ( y['s'] = -b, y ) : new BigNumber( yc ? x : NaN );
+
+ // Either zero?
+ if ( !xc[0] || !yc[0] ) {
+
+ // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
+ return yc[0] ? ( y['s'] = -b, y ) : new BigNumber( xc[0] ? x :
+
+ // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
+ ROUNDING_MODE == 3 ? -0 : 0 );
+ }
+ }
+
+ // Floor xe and ye
+ i = xe | 0;
+ xe = xe > 0 || xe === i ? i : i - 1;
+ i = ye | 0;
+ ye = ye > 0 || ye === i ? i : i - 1;
+ xc = xc.slice();
+
+ // Determine which is the bigger number.
+ if ( a = xe - ye ) {
+
+ if ( xLTy = a < 0 ) {
+ a = -a, t = xc;
+ } else {
+ ye = xe, t = yc;
+ }
+
+ // Prepend zeros to equalise exponents.
+ for ( t.reverse(), b = a; b--; t.push(0) );
+ t.reverse();
+ } else {
+
+ // Exponents equal. Check digit by digit.
+ j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;
+
+ for ( a = b = 0; b < j; b++ ) {
+
+ if ( xc[b] != yc[b] ) {
+ xLTy = xc[b] < yc[b];
+ break;
+ }
+ }
+ }
+
+ // x < y? Point xc to the array of the bigger number.
+ if (xLTy) t = xc, xc = yc, yc = t, y['s'] = -y['s'];
+
+ b = ( j = yc.length ) - ( i = xc.length );
+
+ // Append zeros to xc if shorter.
+ // No need to add zeros to yc if shorter as subtraction only needs to start at yc.length.
+ if ( b > 0 ) for ( ; b--; xc[i++] = 0 );
+ b = BASE - 1;
+
+ // Subtract yc from xc.
+ for ( ; j > a; ) {
+
+ if ( xc[--j] < yc[j] ) {
+ for ( i = j; i && !xc[--i]; xc[i] = b );
+ --xc[i];
+ xc[j] += BASE;
+ }
+ xc[j] -= yc[j];
+ }
+
+ // Remove leading zeros and adjust exponent accordingly.
+ for ( ; xc[0] == 0; xc.shift(), --ye );
+
+ // Zero?
+ if ( !xc[0] ) {
+
+ // Following IEEE 754 (2008) 6.3,
+ // n - n = +0 but n - n = -0 when rounding towards -Infinity.
+ y['s'] = ROUNDING_MODE == 3 ? -1 : 1;
+ y['c'] = [ y['e'] = 0 ];
+ return y;
+ }
+
+ // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity when neither
+ // x or y are Infinity.
+ return normalise( y, xc, ye );
+ };
+
+
+ /*
+ * n % 0 = N
+ * n % N = N
+ * 0 % n = 0
+ * -0 % n = -0
+ * 0 % 0 = N
+ * 0 % N = N
+ * N % n = N
+ * N % 0 = N
+ * N % N = N
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
+ * BigNumber(y, b).
+ */
+ P['modulo'] = P['mod'] = function ( y, b ) {
+ id = 9;
+ var x = this,
+ xc = x['c'],
+ yc = ( y = new BigNumber( y, b ) )['c'],
+ xs = x['s'],
+ ys = y['s'];
+
+ // x or y NaN? y zero? x zero?
+ b = !xs || !ys || yc && !yc[0];
+ if ( b || xc && !xc[0] ) return new BigNumber( b ? NaN : x );
+
+ x['s'] = y['s'] = 1;
+ b = y['cmp'](x) == 1;
+ x['s'] = xs;
+ y['s'] = ys;
+
+ return b ? new BigNumber(x) : x['minus']( div( x, y, 0, 1 )['times'](y) );
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber negated, i.e. multiplied
+ * by -1.
+ */
+ P['negated'] = P['neg'] = function () {
+ var x = new BigNumber(this);
+ x['s'] = -x['s'] || null;
+ return x;
+ };
+
+
+ /*
+ * n + 0 = n
+ * n + N = N
+ * n + I = I
+ * 0 + n = n
+ * 0 + 0 = 0
+ * 0 + N = N
+ * 0 + I = I
+ * N + n = N
+ * N + 0 = N
+ * N + N = N
+ * N + I = N
+ * I + n = I
+ * I + 0 = I
+ * I + N = N
+ * I + I = I
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber plus the value of
+ * BigNumber(y, b).
+ */
+ P['plus'] = function ( y, b ) {
+ var t,
+ x = this,
+ a = x['s'];
+
+ id = 10;
+ y = new BigNumber( y, b );
+ b = y['s'];
+
+ // Either NaN?
+ if ( !a || !b ) return new BigNumber(NaN);
+
+ // Signs differ?
+ if ( a != b ) {
+ y['s'] = -b;
+ return x['minus'](y);
+ }
+
+ var xe = x['e'] / LOG_BASE,
+ ye = y['e'] / LOG_BASE,
+ xc = x['c'],
+ yc = y['c'];
+
+ if ( !xe || !ye ) {
+
+ // Return +-Infinity if either Infinity.
+ if ( !xc || !yc ) return new BigNumber( a / 0 );
+
+ // Either zero? Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
+ if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );
+ }
+
+ // Floor xe and ye
+ a = xe | 0;
+ xe = xe > 0 || xe === a ? a : a - 1;
+ a = ye | 0;
+ ye = ye > 0 || ye === a ? a : a - 1;
+ xc = xc.slice();
+
+ // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
+ if ( a = xe - ye ) {
+ if ( a > 0 ) {
+ ye = xe, t = yc;
+ } else {
+ a = -a, t = xc;
+ }
+
+ for ( t.reverse(); a--; t.push(0) );
+ t.reverse();
+ }
+ a = xc.length;
+ b = yc.length;
+
+ // Point xc to the longer array, and b to the shorter length.
+ if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;
+
+ // Only start adding at yc.length - 1 as the further digits of xc can be left as they are.
+ for ( a = 0; b; ) {
+ a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
+ xc[b] %= BASE;
+ }
+
+
+ if (a) {
+ xc.unshift(a);
+ ++ye;
+ }
+
+ // No need to check for zero, as +x + +y != 0 && -x + -y != 0
+ // ye = MAX_EXP + 1 possible
+ return normalise( y, xc, ye );
+ };
+
+
+ /*
+ * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of dp
+ * decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if omitted.
+ *
+ * [dp] {number} Integer, 0 to MAX inclusive.
+ * [rm] {number} Integer, 0 to 8 inclusive.
+ */
+ P['round'] = function ( dp, rm ) {
+
+ dp = dp == null || ( ( ( outOfRange = dp < 0 || dp > MAX ) || parse(dp) != dp ) &&
+
+ // 'round() decimal places out of range: {dp}'
+ // 'round() decimal places not an integer: {dp}'
+ !ifExceptionsThrow( dp, 'decimal places', 'round' ) ) ? 0 : dp | 0;
+
+ // Include '&& rm !== 0' because with Opera -0 == parseFloat(-0) is false.
+ rm = rm == null || ( ( ( outOfRange = rm < 0 || rm > 8 ) || parse(rm) != rm && rm !== 0 ) &&
+
+ // 'round() mode not an integer: {rm}'
+ // 'round() mode out of range: {rm}'
+ !ifExceptionsThrow( rm, 'mode', 'round' ) ) ? ROUNDING_MODE : rm | 0;
+
+ return rnd( new BigNumber(this), dp + this['e'] + 1, rm );
+ };
+
+
+ /*
+ * sqrt(-n) = N
+ * sqrt( N) = N
+ * sqrt(-I) = N
+ * sqrt( I) = I
+ * sqrt( 0) = 0
+ * sqrt(-0) = -0
+ *
+ * Return a new BigNumber whose value is the square root of the value of this BigNumber,
+ * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
+ */
+ P['squareRoot'] = P['sqrt'] = function () {
+ var m, n, r, rep, t,
+ x = this,
+ c = x['c'],
+ s = x['s'],
+ e = x['e'],
+ dp = DECIMAL_PLACES + 4,
+ half = new BigNumber('0.5');
+
+ // Negative/NaN/Infinity/zero?
+ if ( s !== 1 || !c || !c[0] ) {
+ return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );
+ }
+
+ // Initial estimate.
+ s = Math.sqrt( +x );
+
+ // Math.sqrt underflow/overflow?
+ // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
+ if ( s == 0 || s == 1 / 0 ) {
+ n = coefficientToString(c);
+ if ( ( n.length + e ) % 2 == 0 ) n += '0';
+ s = Math.sqrt(n);
+ e = mathfloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );
+
+ if ( s == 1 / 0 ) {
+ n = '1e' + e;
+ } else {
+ n = s.toExponential();
+ n = n.slice( 0, n.indexOf('e') + 1 ) + e;
+ }
+ r = new BigNumber(n);
+ } else {
+ r = new BigNumber( s.toString() );
+ }
+
+ // Check for zero. r could be zero if MIN_EXP is changed after the this value was created.
+ // This would cause a division by zero (x/t) and hence Infinity below, which would cause
+ // coefficientToString to throw.
+ if ( r['c'][0] ) {
+ e = r['e'];
+ s = e + dp;
+ if ( s < 3 ) s = 0;
+
+ // Newton-Raphson iteration.
+ for ( ; ; ) {
+ t = r;
+ r = half['times']( t['plus']( div( x, t, dp, 1 ) ) );
+
+ if ( coefficientToString( t['c'] ).slice( 0, s ) === ( n =
+ coefficientToString( r['c'] ) ).slice( 0, s ) ) {
+
+ // The exponent of r may here be one less than the final result exponent,
+ // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits are
+ // indexed correctly.
+ if ( r['e'] < e ) --s;
+ n = n.slice( s - 3, s + 1 );
+
+ // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are
+ // 9999 or 4999 (i.e. approaching a rounding boundary) continue the iteration.
+ if ( n == '9999' || !rep && n == '4999' ) {
+
+ // On the first iteration only, check to see if rounding up gives the exact
+ // result as the nines may infinitely repeat.
+ if ( !rep ) {
+ rnd( t, t['e'] + DECIMAL_PLACES + 2, 0 );
+
+ if ( t['times'](t)['eq'](x) ) {
+ r = t;
+ break;
+ }
+ }
+ dp += 4;
+ s += 4;
+ rep = 1;
+ } else {
+
+ // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact result.
+ // If not, then there are further digits and m will be truthy.
+ if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {
+
+ // Truncate to the first rounding digit.
+ rnd( r, r['e'] + DECIMAL_PLACES + 2, 1 );
+ m = !r['times'](r)['eq'](x);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ return rnd( r, r['e'] + DECIMAL_PLACES + 1, ROUNDING_MODE, m );
+ };
+
+
+ /*
+ * n * 0 = 0
+ * n * N = N
+ * n * I = I
+ * 0 * n = 0
+ * 0 * 0 = 0
+ * 0 * N = N
+ * 0 * I = N
+ * N * n = N
+ * N * 0 = N
+ * N * N = N
+ * N * I = N
+ * I * n = I
+ * I * 0 = N
+ * I * N = N
+ * I * I = I
+ *
+ * Return a new BigNumber whose value is the value of this BigNumber times the value of
+ * BigNumber(y, b).
+ */
+ P['times'] = function ( y, b ) {
+ var c, e, k, m, r, xlo, xhi, ylo, yhi,
+ x = this,
+ xc = x['c'],
+ yc = ( id = 11, y = new BigNumber( y, b ) )['c'],
+ i = x['e'] / LOG_BASE,
+ j = y['e'] / LOG_BASE,
+ a = x['s'];
+
+ y['s'] = a == ( b = y['s'] ) ? 1 : -1;
+
+ // Either NaN/Infinity/0?
+ if ( !i && ( !xc || !xc[0] ) || !j && ( !yc || !yc[0] ) ) {
+
+ // Return NaN if either NaN, or x is 0 and y is Infinity, or y is 0 and x is Infinity.
+ return new BigNumber( !a || !b || xc && !xc[0] && !yc || yc && !yc[0] && !xc ? NaN
+
+ // Return +-Infinity if either is Infinity. Return +-0 if x or y is 0.
+ : !xc || !yc ? y['s'] / 0 : y['s'] * 0 );
+ }
+
+ // e = mathfloor(i) + mathfloor(j);
+ e = ( e = i | 0, i > 0 || i === e ? e : e - 1) +
+ ( e = j | 0, j > 0 || j === e ? e : e - 1);
+
+ a = xc.length;
+ b = yc.length;
+
+ // Ensure xc points to longer array and b to longer length.
+ if ( a < b ) r = xc, xc = yc, yc = r, j = a, a = b, b = j;
+
+ // Initialise the result array with zeros.
+ for ( j = a + b, r = []; j--; r.push(0) );
+
+ // Multiply!
+ for ( i = b; --i >= 0; ) {
+ c = 0;
+ j = a + i;
+ k = a;
+ ylo = yc[i] % SQRT_BASE;
+ yhi = yc[i] / SQRT_BASE | 0;
+
+ for ( ; j > i; ) {
+ xlo = xc[--k] % SQRT_BASE;
+ xhi = xc[k] / SQRT_BASE | 0;
+ m = yhi * xlo + xhi * ylo;
+ xlo = ylo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + r[j] + c;
+ c = ( xlo / BASE | 0 ) + ( m / SQRT_BASE | 0 ) + yhi * xhi;
+ r[j--] = xlo % BASE;
+ }
+ r[j] = c;
+ }
+
+ if (c) {
+ ++e;
+ } else {
+ r.shift();
+ }
+
+ return normalise( y, r, e );
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber in exponential notation to dp fixed
+ * decimal places and rounded using ROUNDING_MODE if necessary.
+ *
+ * [dp] {number} Integer, 0 to MAX inclusive.
+ */
+ P['toExponential'] = function (dp) {
+ var x = this;
+
+ return x['c'] ? format( x, dp == null || ( ( outOfRange = dp < 0 || dp > MAX ) ||
+
+ // Include '&& dp !== 0' because with Opera -0 == parseFloat(-0) is false,
+ // despite -0 == parseFloat('-0') && 0 == -0 being true.
+ parse(dp) != dp && dp !== 0 ) &&
+
+ // 'toExponential() decimal places not an integer: {dp}'
+ // 'toExponential() decimal places out of range: {dp}'
+ !ifExceptionsThrow( dp, 'decimal places', 'toExponential' )
+ ? null : dp | 0, 1 ) : x.toString();
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber in normal notation to dp fixed
+ * decimal places and rounded using ROUNDING_MODE if necessary.
+ *
+ * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
+ * but e.g. (-0.00001).toFixed(0) is '-0'.
+ *
+ * [dp] {number} Integer, 0 to MAX inclusive.
+ */
+ P['toFixed'] = function (dp) {
+ var str,
+ x = this,
+ neg = TO_EXP_NEG,
+ pos = TO_EXP_POS;
+
+ dp = dp == null || ( ( outOfRange = dp < 0 || dp > MAX ) ||
+
+ // 'toFixed() decimal places not an integer: {dp}'
+ // 'toFixed() decimal places out of range: {dp}'
+ parse(dp) != dp && dp !== 0 ) && !ifExceptionsThrow( dp, 'decimal places', 'toFixed' )
+ ? null : x['e'] + ( dp | 0 );
+
+ TO_EXP_NEG = -( TO_EXP_POS = 1 / 0 );
+
+ if ( dp == null || !x['c'] ) {
+ str = x.toString();
+ } else {
+ str = format( x, dp );
+
+ // (-0).toFixed() is '0', but (-0.1).toFixed() is '-0'.
+ // (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
+ if ( x['s'] < 0 && x['c'] ) {
+
+ // As e.g. (-0).toFixed(3), will wrongly be returned as -0.000 from toString.
+ if ( !x['c'][0] ) {
+ str = str.replace( '-', '' );
+
+ // As e.g. -0.5 if rounded to -0 will cause toString to omit the minus sign.
+ } else if ( str.indexOf('-') < 0 ) {
+ str = '-' + str;
+ }
+ }
+ }
+
+ TO_EXP_NEG = neg;
+ TO_EXP_POS = pos;
+
+ return str;
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber in fixed-point notation rounded
+ * using ROUNDING_MODE to dp decimal places, and formatted according to the properties of the
+ * FORMAT object (see BigNumber.config).
+ *
+ * FORMAT = {
+ * decimalSeparator : '.',
+ * groupSeparator : ',',
+ * groupSize : 3,
+ * secondaryGroupSize : 0,
+ * fractionGroupSeparator : '\xA0', // non-breaking space
+ * fractionGroupSize : 0
+ * };
+ *
+ * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
+ * (TODO: If dp is invalid the error message will give toFixed as the offending method.)
+ */
+ P['toFormat'] = function (dp) {
+ var x = this;
+
+ if ( !x['c'] ) return x.toString();
+
+ var i,
+ isNeg = x['s'] < 0,
+ groupSeparator = FORMAT['groupSeparator'],
+ g1 = +FORMAT['groupSize'],
+ g2 = +FORMAT['secondaryGroupSize'],
+ arr = x.toFixed(dp).split('.'),
+ intPart = arr[0],
+ fractionPart = arr[1],
+ intDigits = isNeg ? intPart.slice(1) : intPart,
+ len = intDigits.length;
+
+ if (g2) i = g1, g1 = g2, g2 = i, len -= i;
+
+ if ( g1 > 0 && len > 0 ) {
+ i = len % g1 || g1;
+ intPart = intDigits.substr( 0, i );
+ for ( ; i < len; i += g1 ) intPart += groupSeparator + intDigits.substr( i, g1 );
+ if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);
+ if (isNeg) intPart = '-' + intPart;
+ }
+
+ return fractionPart
+ ? intPart + FORMAT['decimalSeparator'] + ( ( g2 = +FORMAT['fractionGroupSize'] )
+ ? fractionPart.replace( new RegExp( '\\d{' + g2 + '}\\B', 'g' ),
+ '$&' + FORMAT['fractionGroupSeparator'] )
+ : fractionPart )
+ : intPart;
+ };
+
+
+ /*
+ * Return a string array representing the value of this BigNumber as a simple fraction with an
+ * integer numerator and an integer denominator. The denominator will be a positive non-zero
+ * value less than or equal to the specified maximum denominator. If a maximum denominator is
+ * not specified, the denominator will be the lowest value necessary to represent the number
+ * exactly.
+ *
+ * [maxD] {number|string|BigNumber} Integer >= 1 and < Infinity.
+ */
+ P['toFraction'] = function (maxD) {
+ var arr, d0, d2, e, exp, n, n0, q, s,
+ n1 = d0 = new BigNumber(ONE),
+ d1 = n0 = new BigNumber(ONE),
+ x = this,
+ xc = x['c'],
+ d = new BigNumber(ONE);
+
+ // NaN, Infinity.
+ if ( !xc ) return x.toString();
+ s = coefficientToString(xc);
+
+ // Initial denominator.
+ e = d['e'] = s.length - x['e'] - 1;
+ d['c'][0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];
+
+ // If max denominator is undefined or null, or NaN...
+ if ( maxD == null || ( !( id = 12, n = new BigNumber(maxD) )['s'] ||
+
+ // or less than 1, or Infinity...
+ ( outOfRange = n['cmp'](n1) < 0 || !n['c'] ) ||
+
+ // or not an integer...
+ ( ERRORS && mathfloor( n['e'] / LOG_BASE ) < n['c'].length - 1 ) ) &&
+
+ // 'toFraction() max denominator not an integer: {maxD}'
+ // 'toFraction() max denominator out of range: {maxD}'
+ !ifExceptionsThrow( maxD, 'max denominator', 'toFraction' ) ||
+
+ // or greater than the max denominator needed to specify the value exactly...
+ ( maxD = n )['cmp'](d) > 0 ) {
+
+ // d is e.g. 10, 100, 1000, 10000... , n1 is 1.
+ maxD = e > 0 ? d : n1;
+ }
+
+ exp = MAX_EXP;
+ MAX_EXP = 1 / 0;
+ n = new BigNumber(s);
+
+ // n0 = d1 = 0
+ n0['c'][0] = 0;
+
+ for ( ; ; ) {
+ q = div( n, d, 0, 1 );
+ d2 = d0['plus']( q['times'](d1) );
+ if ( d2['cmp'](maxD) == 1 ) break;
+ d0 = d1;
+ d1 = d2;
+ n1 = n0['plus']( q['times']( d2 = n1 ) );
+ n0 = d2;
+ d = n['minus']( q['times']( d2 = d ) );
+ n = d2;
+ }
+
+ d2 = div( maxD['minus'](d0), d1, 0, 1 );
+ n0 = n0['plus']( d2['times'](n1) );
+ d0 = d0['plus']( d2['times'](d1) );
+ n0['s'] = n1['s'] = x['s'];
+ e *= 2;
+
+ // Determine which fraction is closer to x, n0/d0 or n1/d1
+ arr = div( n1, d1, e, ROUNDING_MODE )['minus'](x)['abs']()['cmp'](
+ div( n0, d0, e, ROUNDING_MODE )['minus'](x)['abs']() ) < 1
+ ? [ n1.toString(), d1.toString() ]
+ : [ n0.toString(), d0.toString() ];
+
+ MAX_EXP = exp;
+
+ return arr;
+ };
+
+
+ /*
+ * Return the value of this BigNumber converted to a number primitive.
+ */
+ P['toNumber'] = function () {
+ var x = this;
+
+ // Ensure zero has correct sign.
+ return +x || ( x['s'] ? 0 * x['s'] : NaN );
+ };
+
+
+ /*
+ * Return a BigNumber whose value is the value of this BigNumber raised to the power e.
+ * If e is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
+ *
+ * e {number} Integer, -MAX_POWER to MAX_POWER inclusive.
+ */
+ P['toPower'] = P['pow'] = function (e) {
+
+ // e to integer, avoiding NaN or Infinity becoming 0.
+ var i = e * 0 == 0 ? ~~e : e,
+ x = new BigNumber(this),
+ y = new BigNumber(ONE);
+
+ // Pass +-Infinity for out of range exponents.
+ if ( ( ( ( outOfRange = e < -MAX_POWER || e > MAX_POWER ) && (i = e * 1 / 0) ) ||
+
+ // Any exponent that fails the parse becomes NaN.
+ // Include 'e !== 0' because on Opera -0 == parseFloat(-0) is false, despite
+ // -0 === parseFloat(-0) && -0 == parseFloat('-0') evaluating true.
+ parse(e) != e && e !== 0 && !(i = NaN) ) &&
+
+ // 'pow() exponent not an integer: {e}'
+ // 'pow() exponent out of range: {e}'
+ // Pass zero to Math.pow, as any value to the power zero is 1.
+ !ifExceptionsThrow( e, 'exponent', 'pow' ) || !i ) {
+
+ // i is +-Infinity, NaN or 0.
+ return new BigNumber( Math.pow( +x, i ) );
+ }
+ i = i < 0 ? -i : i;
+
+ for ( ; ; ) {
+ if ( i & 1 ) y = y['times'](x);
+ i >>= 1;
+ if ( !i ) break;
+ x = x['times'](x);
+ }
+
+ return e < 0 ? ONE['div'](y) : y;
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber to sd significant digits and rounded
+ * using ROUNDING_MODE if necessary. If sd is less than the number of digits necessary to
+ * represent the integer part of the value in normal notation, then use exponential notation.
+ *
+ * sd {number} Integer, 1 to MAX inclusive.
+ */
+ P['toPrecision'] = function (sd) {
+ var x = this;
+
+ // ERRORS true: Throw if sd not undefined, null or an integer in range.
+ // ERRORS false: Ignore sd if not a number or not in range.
+ // Truncate non-integers.
+ return sd == null || ( ( ( outOfRange = sd < 1 || sd > MAX ) || parse(sd) != sd ) &&
+
+ // 'toPrecision() precision not an integer: {sd}'
+ // 'toPrecision() precision out of range: {sd}'
+ !ifExceptionsThrow( sd, 'precision', 'toPrecision' ) ) || !x['c']
+ ? x.toString() : format( x, --sd | 0, 2 );
+ };
+
+
+ /*
+ * Return a string representing the value of this BigNumber in base b, or base 10 if b is
+ * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
+ * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent that is
+ * equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than TO_EXP_NEG,
+ * return exponential notation.
+ *
+ * [b] {number} Integer, 2 to 64 inclusive.
+ */
+ P['toString'] = function (b) {
+ var u, str, strL,
+ x = this,
+ xe = x['e'];
+
+ // Infinity or NaN?
+ if ( xe === null ) {
+ str = x['s'] ? 'Infinity' : 'NaN';
+
+ // Exponential format?
+ } else if ( b == u && ( xe <= TO_EXP_NEG || xe >= TO_EXP_POS ) ) {
+ return format( x, u, 1 );
+ } else {
+ str = coefficientToString( x['c'] );
+
+ // Negative exponent?
+ if ( xe < 0 ) {
+
+ // Prepend zeros.
+ for ( ; ++xe; str = '0' + str );
+ str = '0.' + str;
+
+ // Positive exponent?
+ } else if ( strL = str.length, xe > 0 ) {
+
+ // Append zeros.
+ if ( ++xe > strL ) {
+ for ( xe -= strL; xe-- ; str += '0' );
+ } else if ( xe < strL ) {
+ str = str.slice( 0, xe ) + '.' + str.slice(xe);
+ }
+
+ // Exponent zero.
+ } else {
+ u = str.charAt(0);
+
+ if ( strL > 1 ) {
+ str = u + '.' + str.slice(1);
+
+ // Avoid '-0'
+ } else if ( u == '0' ) {
+ return u;
+ }
+ }
+
+ if ( b != null ) {
+
+ if ( !( outOfRange = !( b >= 2 && b < 65 ) ) && ( b == ~~b || !ERRORS ) ) {
+ str = convertBase( str, b | 0, 10, x['s'] );
+
+ // Avoid '-0'
+ if ( str == '0' ) return str;
+ } else {
+
+ // 'toString() base not an integer: {b}'
+ // 'toString() base out of range: {b}'
+ ifExceptionsThrow( b, 'base', 'toS' );
+ }
+ }
+
+ }
+
+ return x['s'] < 0 ? '-' + str : str;
+ };
+
+
+ /*
+ * Return as toString, but do not accept a base argument.
+ */
+ P['valueOf'] = P['toJSON'] = function () {
+ return this.toString();
+ };
+
+
+ // Add aliases for BigDecimal methods.
+ //P['add'] = P['plus'];
+ //P['subtract'] = P['minus'];
+ //P['multiply'] = P['times'];
+ //P['divide'] = P['div'];
+ //P['remainder'] = P['mod'];
+ //P['compareTo'] = P['cmp'];
+ //P['negate'] = P['neg'];
+
+
+ // EXPORT
+
+
+ // Node and other CommonJS-like environments that support module.exports.
+ if ( typeof module !== 'undefined' && module.exports ) {
+ module.exports = BigNumber;
+ //AMD.
+ } else if ( typeof define == 'function' && define.amd ) {
+ define( function () {return BigNumber} );
+ //Browser.
+ } else {
+ global['BigNumber'] = BigNumber;
+ }
+})(this);
+
+},{}],"web3":[function(require,module,exports){
+// dont override global variable
+if (typeof web3 !== 'undefined') {
+ var web3;
+}
+
+web3 = require('./lib/web3');
+web3.providers.HttpProvider = require('./lib/web3/httpprovider');
+web3.providers.QtSyncProvider = require('./lib/web3/qtsync');
+web3.eth.contract = require('./lib/web3/contract');
+web3.abi = require('./lib/solidity/abi');
+
+
+
+module.exports = web3;
+
+},{"./lib/solidity/abi":1,"./lib/web3":9,"./lib/web3/contract":10,"./lib/web3/httpprovider":17,"./lib/web3/qtsync":22}]},{},["web3"])
+
+
+//# sourceMappingURL=web3.js.map
\ No newline at end of file
diff --git a/libjsqrc/ethereumjs/dist/web3.js.map b/libjsqrc/ethereumjs/dist/web3.js.map
new file mode 100644
index 000000000..c4a077064
--- /dev/null
+++ b/libjsqrc/ethereumjs/dist/web3.js.map
@@ -0,0 +1,69 @@
+{
+ "version": 3,
+ "sources": [
+ "node_modules/browserify/node_modules/browser-pack/_prelude.js",
+ "lib/solidity/abi.js",
+ "lib/solidity/formatters.js",
+ "lib/solidity/types.js",
+ "lib/utils/browser-bn.js",
+ "lib/utils/browser-xhr.js",
+ "lib/utils/config.js",
+ "lib/utils/utils.js",
+ "lib/version.json",
+ "lib/web3.js",
+ "lib/web3/contract.js",
+ "lib/web3/db.js",
+ "lib/web3/errors.js",
+ "lib/web3/eth.js",
+ "lib/web3/event.js",
+ "lib/web3/filter.js",
+ "lib/web3/formatters.js",
+ "lib/web3/httpprovider.js",
+ "lib/web3/jsonrpc.js",
+ "lib/web3/method.js",
+ "lib/web3/net.js",
+ "lib/web3/property.js",
+ "lib/web3/qtsync.js",
+ "lib/web3/requestmanager.js",
+ "lib/web3/shh.js",
+ "lib/web3/signature.js",
+ "lib/web3/watches.js",
+ "node_modules/bignumber.js/bignumber.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;;ACrPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7EA;AACA;AACA;AACA;AACA;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1eA;AACA;AACA;AACA;;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3NA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpvEA;AACA;AACA;AACA;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.\n*/\n/** @file abi.js\n * @authors:\n * Marek Kotewicz \n * Gav Wood \n * @date 2014\n */\n\nvar utils = require('../utils/utils');\nvar c = require('../utils/config');\nvar types = require('./types');\nvar f = require('./formatters');\n\n/**\n * throw incorrect type error\n *\n * @method throwTypeError\n * @param {String} type\n * @throws incorrect type error\n */\nvar throwTypeError = function (type) {\n throw new Error('parser does not support type: ' + type);\n};\n\n/** This method should be called if we want to check if givent type is an array type\n *\n * @method isArrayType\n * @param {String} type name\n * @returns {Boolean} true if it is, otherwise false\n */\nvar isArrayType = function (type) {\n return type.slice(-2) === '[]';\n};\n\n/**\n * This method should be called to return dynamic type length in hex\n *\n * @method dynamicTypeBytes\n * @param {String} type\n * @param {String|Array} dynamic type\n * @return {String} length of dynamic type in hex or empty string if type is not dynamic\n */\nvar dynamicTypeBytes = function (type, value) {\n // TODO: decide what to do with array of strings\n if (isArrayType(type) || type === 'bytes')\n return f.formatInputInt(value.length);\n return \"\";\n};\n\nvar inputTypes = types.inputTypes();\n\n/**\n * Formats input params to bytes\n *\n * @method formatInput\n * @param {Array} abi inputs of method\n * @param {Array} params that will be formatted to bytes\n * @returns bytes representation of input params\n */\nvar formatInput = function (inputs, params) {\n var bytes = \"\";\n var toAppendConstant = \"\";\n var toAppendArrayContent = \"\";\n\n /// first we iterate in search for dynamic\n inputs.forEach(function (input, index) {\n bytes += dynamicTypeBytes(input.type, params[index]);\n });\n\n inputs.forEach(function (input, i) {\n /*jshint maxcomplexity:5 */\n var typeMatch = false;\n for (var j = 0; j < inputTypes.length && !typeMatch; j++) {\n typeMatch = inputTypes[j].type(inputs[i].type, params[i]);\n }\n if (!typeMatch) {\n throwTypeError(inputs[i].type);\n }\n\n var formatter = inputTypes[j - 1].format;\n\n if (isArrayType(inputs[i].type))\n toAppendArrayContent += params[i].reduce(function (acc, curr) {\n return acc + formatter(curr);\n }, \"\");\n else if (inputs[i].type === 'bytes')\n toAppendArrayContent += formatter(params[i]);\n else\n toAppendConstant += formatter(params[i]);\n });\n\n bytes += toAppendConstant + toAppendArrayContent;\n\n return bytes;\n};\n\n/**\n * This method should be called to predict the length of dynamic type\n *\n * @method dynamicBytesLength\n * @param {String} type\n * @returns {Number} length of dynamic type, 0 or multiplication of ETH_PADDING (32)\n */\nvar dynamicBytesLength = function (type) {\n if (isArrayType(type) || type === 'bytes')\n return c.ETH_PADDING * 2;\n return 0;\n};\n\nvar outputTypes = types.outputTypes();\n\n/** \n * Formats output bytes back to param list\n *\n * @method formatOutput\n * @param {Array} abi outputs of method\n * @param {String} bytes represention of output\n * @returns {Array} output params\n */\nvar formatOutput = function (outs, output) {\n\n output = output.slice(2);\n var result = [];\n var padding = c.ETH_PADDING * 2;\n\n var dynamicPartLength = outs.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 outs.forEach(function (out, i) {\n /*jshint maxcomplexity:6 */\n var typeMatch = false;\n for (var j = 0; j < outputTypes.length && !typeMatch; j++) {\n typeMatch = outputTypes[j].type(outs[i].type);\n }\n\n if (!typeMatch) {\n throwTypeError(outs[i].type);\n }\n\n var formatter = outputTypes[j - 1].format;\n if (isArrayType(outs[i].type)) {\n var size = f.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 (types.prefixedType('bytes')(outs[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/**\n * Should be called to create input parser for contract with given abi\n *\n * @method inputParser\n * @param {Array} contract abi\n * @returns {Object} input parser object for given json abi\n * TODO: refactor creating the parser, do not double logic from contract\n */\nvar inputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n return formatInput(method.inputs, 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/**\n * Should be called to create output parser for contract with given abi\n *\n * @method outputParser\n * @param {Array} contract abi\n * @returns {Object} output parser for given json abi\n */\nvar outputParser = function (json) {\n var parser = {};\n json.forEach(function (method) {\n\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function (output) {\n return formatOutput(method.outputs, 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\nmodule.exports = {\n inputParser: inputParser,\n outputParser: outputParser,\n formatInput: formatInput,\n formatOutput: formatOutput\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 .\n*/\n/** @file formatters.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar BigNumber = require('bignumber.js');\nvar utils = require('../utils/utils');\nvar c = require('../utils/config');\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 *\n * @method formatInputInt\n * @param {String|Number|BigNumber} value that needs to be formatted\n * @returns {String} right-aligned byte representation of int\n */\nvar formatInputInt = function (value) {\n var padding = c.ETH_PADDING * 2;\n BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);\n return utils.padLeft(utils.toTwosComplement(value).round().toString(16), padding);\n};\n\n/**\n * Formats input value to byte representation of string\n *\n * @method formatInputString\n * @param {String}\n * @returns {String} left-algined byte representation of string\n */\nvar formatInputString = function (value) {\n return utils.fromAscii(value, c.ETH_PADDING).substr(2);\n};\n\n/**\n * Formats input value to byte representation of bool\n *\n * @method formatInputBool\n * @param {Boolean}\n * @returns {String} right-aligned byte representation bool\n */\nvar formatInputBool = function (value) {\n return '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');\n};\n\n/**\n * Formats input value to byte representation of real\n * Values are multiplied by 2^m and encoded as integers\n *\n * @method formatInputReal\n * @param {String|Number|BigNumber}\n * @returns {String} byte representation of real\n */\nvar formatInputReal = function (value) {\n return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128))); \n};\n\n/**\n * Check if input value is negative\n *\n * @method signedIsNegative\n * @param {String} value is hex format\n * @returns {Boolean} true if it is negative, otherwise false\n */\nvar signedIsNegative = function (value) {\n return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';\n};\n\n/**\n * Formats right-aligned output bytes to int\n *\n * @method formatOutputInt\n * @param {String} bytes\n * @returns {BigNumber} right-aligned output bytes formatted to big number\n */\nvar formatOutputInt = function (value) {\n\n value = value || \"0\";\n\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/**\n * Formats right-aligned output bytes to uint\n *\n * @method formatOutputUInt\n * @param {String} bytes\n * @returns {BigNumeber} right-aligned output bytes formatted to uint\n */\nvar formatOutputUInt = function (value) {\n value = value || \"0\";\n return new BigNumber(value, 16);\n};\n\n/**\n * Formats right-aligned output bytes to real\n *\n * @method formatOutputReal\n * @param {String}\n * @returns {BigNumber} input bytes formatted to real\n */\nvar formatOutputReal = function (value) {\n return formatOutputInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/**\n * Formats right-aligned output bytes to ureal\n *\n * @method formatOutputUReal\n * @param {String}\n * @returns {BigNumber} input bytes formatted to ureal\n */\nvar formatOutputUReal = function (value) {\n return formatOutputUInt(value).dividedBy(new BigNumber(2).pow(128)); \n};\n\n/**\n * Should be used to format output hash\n *\n * @method formatOutputHash\n * @param {String}\n * @returns {String} right-aligned output bytes formatted to hex\n */\nvar formatOutputHash = function (value) {\n return \"0x\" + value;\n};\n\n/**\n * Should be used to format output bool\n *\n * @method formatOutputBool\n * @param {String}\n * @returns {Boolean} right-aligned input bytes formatted to bool\n */\nvar formatOutputBool = function (value) {\n return value === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;\n};\n\n/**\n * Should be used to format output string\n *\n * @method formatOutputString\n * @param {Sttring} left-aligned hex representation of string\n * @returns {String} ascii string\n */\nvar formatOutputString = function (value) {\n return utils.toAscii(value);\n};\n\n/**\n * Should be used to format output address\n *\n * @method formatOutputAddress\n * @param {String} right-aligned input bytes\n * @returns {String} address\n */\nvar formatOutputAddress = function (value) {\n return \"0x\" + value.slice(value.length - 40, value.length);\n};\n\nmodule.exports = {\n formatInputInt: formatInputInt,\n formatInputString: formatInputString,\n formatInputBool: formatInputBool,\n formatInputReal: formatInputReal,\n formatOutputInt: formatOutputInt,\n formatOutputUInt: formatOutputUInt,\n formatOutputReal: formatOutputReal,\n formatOutputUReal: formatOutputUReal,\n formatOutputHash: formatOutputHash,\n formatOutputBool: formatOutputBool,\n formatOutputString: formatOutputString,\n formatOutputAddress: formatOutputAddress\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 .\n*/\n/** @file types.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar f = require('./formatters');\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\n/// Setups input formatters for solidity types\n/// @returns an array of input formatters \nvar inputTypes = function () {\n \n return [\n { type: prefixedType('uint'), format: f.formatInputInt },\n { type: prefixedType('int'), format: f.formatInputInt },\n { type: prefixedType('bytes'), format: f.formatInputString }, \n { type: prefixedType('real'), format: f.formatInputReal },\n { type: prefixedType('ureal'), format: f.formatInputReal },\n { type: namedType('address'), format: f.formatInputInt },\n { type: namedType('bool'), format: f.formatInputBool }\n ];\n};\n\n/// Setups output formaters for solidity types\n/// @returns an array of output formatters\nvar outputTypes = function () {\n\n return [\n { type: prefixedType('uint'), format: f.formatOutputUInt },\n { type: prefixedType('int'), format: f.formatOutputInt },\n { type: prefixedType('bytes'), format: f.formatOutputString },\n { type: prefixedType('real'), format: f.formatOutputReal },\n { type: prefixedType('ureal'), format: f.formatOutputUReal },\n { type: namedType('address'), format: f.formatOutputAddress },\n { type: namedType('bool'), format: f.formatOutputBool }\n ];\n};\n\nmodule.exports = {\n prefixedType: prefixedType,\n namedType: namedType,\n inputTypes: inputTypes,\n outputTypes: outputTypes\n};\n\n",
+ "'use strict';\n\nmodule.exports = BigNumber; // jshint ignore:line\n\n",
+ "'use strict';\n\n// go env doesn't have and need XMLHttpRequest\nif (typeof XMLHttpRequest === 'undefined') {\n exports.XMLHttpRequest = {};\n} else {\n exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line\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 .\n*/\n/** @file config.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\n/**\n * Utils\n * \n * @module utils\n */\n\n/**\n * Utility functions\n * \n * @class [utils] config\n * @constructor\n */\n\n/// required to define ETH_BIGNUMBER_ROUNDING_MODE\nvar BigNumber = require('bignumber.js');\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\nmodule.exports = {\n ETH_PADDING: 32,\n ETH_SIGNATURE_LENGTH: 4,\n ETH_UNITS: ETH_UNITS,\n ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },\n ETH_POLLING_TIMEOUT: 1000,\n ETH_DEFAULTBLOCK: 'latest'\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 .\n*/\n/** @file utils.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\n/**\n * Utils\n * \n * @module utils\n */\n\n/**\n * Utility functions\n * \n * @class [utils] utils\n * @constructor\n */\n\nvar BigNumber = require('bignumber.js');\n\nvar unitMap = {\n 'wei': '1',\n 'kwei': '1000',\n 'ada': '1000',\n 'mwei': '1000000',\n 'babbage': '1000000',\n 'gwei': '1000000000',\n 'shannon': '1000000000',\n 'szabo': '1000000000000',\n 'finney': '1000000000000000',\n 'ether': '1000000000000000000',\n 'kether': '1000000000000000000000',\n 'grand': '1000000000000000000000',\n 'einstein': '1000000000000000000000',\n 'mether': '1000000000000000000000000',\n 'gether': '1000000000000000000000000000',\n 'tether': '1000000000000000000000000000000'\n};\n\n/**\n * Should be called to pad string to expected length\n *\n * @method padLeft\n * @param {String} string to be padded\n * @param {Number} characters that result string should have\n * @param {String} sign, by default 0\n * @returns {String} right aligned string\n */\nvar padLeft = function (string, chars, sign) {\n return new Array(chars - string.length + 1).join(sign ? sign : \"0\") + string;\n};\n\n/** Finds first index of array element matching pattern\n *\n * @method findIndex\n * @param {Array}\n * @param {Function} pattern\n * @returns {Number} index of element\n */\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/** \n * Should be called to get sting from it's hex representation\n *\n * @method toAscii\n * @param {String} string in hex\n * @returns {String} ascii string representation of hex value\n */\nvar 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 }\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/**\n * Shold be called to get hex representation (prefixed by 0x) of ascii string \n *\n * @method fromAscii\n * @param {String} string\n * @returns {String} hex representation of input string\n */\nvar toHexNative = 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/**\n * Shold be called to get hex representation (prefixed by 0x) of ascii string \n *\n * @method fromAscii\n * @param {String} string\n * @param {Number} optional padding\n * @returns {String} hex representation of input string\n */\nvar fromAscii = function(str, pad) {\n pad = pad === undefined ? 0 : pad;\n var hex = toHexNative(str);\n while (hex.length < pad*2)\n hex += \"00\";\n return \"0x\" + hex;\n};\n\n/**\n * Should be called to get display name of contract function\n * \n * @method extractDisplayName\n * @param {String} name of function/event\n * @returns {String} display name for function/event eg. multiply(uint256) -> multiply\n */\nvar extractDisplayName = function (name) {\n var length = name.indexOf('('); \n return length !== -1 ? name.substr(0, length) : name;\n};\n\n/// @returns overloaded part of function/event name\nvar extractTypeName = function (name) {\n /// TODO: make it invulnerable\n var length = name.indexOf('(');\n return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : \"\";\n};\n\n/**\n * Filters all functions from input abi\n *\n * @method filterFunctions\n * @param {Array} abi\n * @returns {Array} abi array with filtered objects of type 'function'\n */\nvar filterFunctions = function (json) {\n return json.filter(function (current) {\n return current.type === 'function'; \n }); \n};\n\n/**\n * Filters all events from input abi\n *\n * @method filterEvents\n * @param {Array} abi\n * @returns {Array} abi array with filtered objects of type 'event'\n */\nvar filterEvents = function (json) {\n return json.filter(function (current) {\n return current.type === 'event';\n });\n};\n\n/**\n * Converts value to it's decimal representation in string\n *\n * @method toDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar toDecimal = function (value) {\n return toBigNumber(value).toNumber();\n};\n\n/**\n * Converts value to it's hex representation\n *\n * @method fromDecimal\n * @param {String|Number|BigNumber}\n * @return {String}\n */\nvar fromDecimal = function (value) {\n var number = toBigNumber(value);\n var result = number.toString(16);\n\n return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;\n};\n\n/**\n * Auto converts any given value into it's hex representation.\n *\n * And even stringifys objects before.\n *\n * @method toHex\n * @param {String|Number|BigNumber|Object}\n * @return {String}\n */\nvar toHex = function (val) {\n /*jshint maxcomplexity:7 */\n\n if (isBoolean(val))\n return fromDecimal(+val);\n\n if (isBigNumber(val))\n return fromDecimal(val);\n\n if (isObject(val))\n return fromAscii(JSON.stringify(val));\n\n // if its a negative number, pass it through fromDecimal\n if (isString(val)) {\n if (val.indexOf('-0x') === 0)\n return fromDecimal(val);\n else if (!isFinite(val))\n return fromAscii(val);\n }\n\n return fromDecimal(val);\n};\n\n/**\n * Returns value of unit in Wei\n *\n * @method getValueOfUnit\n * @param {String} unit the unit to convert to, default ether\n * @returns {BigNumber} value of the unit (in Wei)\n * @throws error if the unit is not correct:w\n */\nvar getValueOfUnit = function (unit) {\n unit = unit ? unit.toLowerCase() : 'ether';\n var unitValue = unitMap[unit];\n if (unitValue === undefined) {\n throw new Error('This unit doesn\\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));\n }\n return new BigNumber(unitValue, 10);\n};\n\n/**\n * Takes a number of wei and converts it to any other ether unit.\n *\n * Possible units are:\n * - kwei/ada\n * - mwei/babbage\n * - gwei/shannon\n * - szabo\n * - finney\n * - ether\n * - kether/grand/einstein\n * - mether\n * - gether\n * - tether\n *\n * @method fromWei\n * @param {Number|String} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert to, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar fromWei = function(number, unit) {\n var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10); \n};\n\n/**\n * Takes a number of a unit and converts it to wei.\n *\n * Possible units are:\n * - kwei/ada\n * - mwei/babbage\n * - gwei/shannon\n * - szabo\n * - finney\n * - ether\n * - kether/grand/einstein\n * - mether\n * - gether\n * - tether\n *\n * @method toWei\n * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal\n * @param {String} unit the unit to convert from, default ether\n * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number\n*/\nvar toWei = function(number, unit) {\n var returnValue = toBigNumber(number).times(getValueOfUnit(unit));\n\n return isBigNumber(number) ? returnValue : returnValue.toString(10); \n};\n\n/**\n * Takes an input and transforms it into an bignumber\n *\n * @method toBigNumber\n * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber\n * @return {BigNumber} BigNumber\n*/\nvar toBigNumber = function(number) {\n /*jshint maxcomplexity:5 */\n number = number || 0;\n if (isBigNumber(number))\n return number;\n\n if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {\n return new BigNumber(number.replace('0x',''), 16);\n }\n \n return new BigNumber(number.toString(10), 10);\n};\n\n/**\n * Takes and input transforms it into bignumber and if it is negative value, into two's complement\n *\n * @method toTwosComplement\n * @param {Number|String|BigNumber}\n * @return {BigNumber}\n */\nvar toTwosComplement = function (number) {\n var bigNumber = toBigNumber(number);\n if (bigNumber.lessThan(0)) {\n return new BigNumber(\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\", 16).plus(bigNumber).plus(1);\n }\n return bigNumber;\n};\n\n/**\n * Checks if the given string has proper length\n *\n * @method isAddress\n * @param {String} address the given HEX adress\n * @return {Boolean}\n*/\nvar isAddress = function (address) {\n return /^0x[0-9a-f]{40}$/.test(address);\n};\n\n/**\n * Transforms given string to valid 20 bytes-length addres with 0x prefix\n *\n * @method toAddress\n * @param {String} address\n * @return {String} formatted address\n */\nvar toAddress = function (address) {\n if (isAddress(address)) {\n return address;\n }\n \n if (/^[0-9a-f]{40}$/.test(address)) {\n return '0x' + address;\n }\n\n return '0x' + padLeft(toHex(address).substr(2), 40);\n};\n\n/**\n * Returns true if object is BigNumber, otherwise false\n *\n * @method isBigNumber\n * @param {Object}\n * @return {Boolean} \n */\nvar isBigNumber = function (object) {\n return object instanceof BigNumber ||\n (object && object.constructor && object.constructor.name === 'BigNumber');\n};\n\n/**\n * Returns true if object is string, otherwise false\n * \n * @method isString\n * @param {Object}\n * @return {Boolean}\n */\nvar isString = function (object) {\n return typeof object === 'string' ||\n (object && object.constructor && object.constructor.name === 'String');\n};\n\n/**\n * Returns true if object is function, otherwise false\n *\n * @method isFunction\n * @param {Object}\n * @return {Boolean}\n */\nvar isFunction = function (object) {\n return typeof object === 'function';\n};\n\n/**\n * Returns true if object is Objet, otherwise false\n *\n * @method isObject\n * @param {Object}\n * @return {Boolean}\n */\nvar isObject = function (object) {\n return typeof object === 'object';\n};\n\n/**\n * Returns true if object is boolean, otherwise false\n *\n * @method isBoolean\n * @param {Object}\n * @return {Boolean}\n */\nvar isBoolean = function (object) {\n return typeof object === 'boolean';\n};\n\n/**\n * Returns true if object is array, otherwise false\n *\n * @method isArray\n * @param {Object}\n * @return {Boolean}\n */\nvar isArray = function (object) {\n return object instanceof Array; \n};\n\n/**\n * Returns true if given string is valid json object\n * \n * @method isJson\n * @param {String}\n * @return {Boolean}\n */\nvar isJson = function (str) {\n try {\n return !!JSON.parse(str);\n } catch (e) {\n return false;\n }\n};\n\nmodule.exports = {\n padLeft: padLeft,\n findIndex: findIndex,\n toHex: toHex,\n toDecimal: toDecimal,\n fromDecimal: fromDecimal,\n toAscii: toAscii,\n fromAscii: fromAscii,\n extractDisplayName: extractDisplayName,\n extractTypeName: extractTypeName,\n filterFunctions: filterFunctions,\n filterEvents: filterEvents,\n toWei: toWei,\n fromWei: fromWei,\n toBigNumber: toBigNumber,\n toTwosComplement: toTwosComplement,\n toAddress: toAddress,\n isBigNumber: isBigNumber,\n isAddress: isAddress,\n isFunction: isFunction,\n isString: isString,\n isObject: isObject,\n isBoolean: isBoolean,\n isArray: isArray,\n isJson: isJson\n};\n\n",
+ "module.exports={\n \"version\": \"0.2.5\"\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 .\n*/\n/** @file web3.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * Gav Wood \n * @date 2014\n */\n\nvar version = require('./version.json');\nvar net = require('./web3/net');\nvar eth = require('./web3/eth');\nvar db = require('./web3/db');\nvar shh = require('./web3/shh');\nvar watches = require('./web3/watches');\nvar Filter = require('./web3/filter');\nvar utils = require('./utils/utils');\nvar formatters = require('./web3/formatters');\nvar RequestManager = require('./web3/requestmanager');\nvar c = require('./utils/config');\nvar Method = require('./web3/method');\nvar Property = require('./web3/property');\n\nvar web3Methods = [\n new Method({\n name: 'sha3',\n call: 'web3_sha3',\n params: 1\n })\n];\n\nvar web3Properties = [\n new Property({\n name: 'version.client',\n getter: 'web3_clientVersion'\n }),\n new Property({\n name: 'version.network',\n getter: 'net_version',\n inputFormatter: utils.toDecimal\n }),\n new Property({\n name: 'version.ethereum',\n getter: 'eth_version',\n inputFormatter: utils.toDecimal\n }),\n new Property({\n name: 'version.whisper',\n getter: 'shh_version',\n inputFormatter: utils.toDecimal\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 method.attachToObject(obj);\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 property.attachToObject(obj);\n });\n};\n\n/// setups web3 object, and it's in-browser executed methods\nvar web3 = {};\nweb3.providers = {};\nweb3.version = {};\nweb3.version.api = version.version;\nweb3.eth = {};\n\n/*jshint maxparams:4 */\nweb3.eth.filter = function (fil, eventParams, options, formatter) {\n\n // if its event, treat it differently\n // TODO: simplify and remove\n if (fil._isEvent) {\n return fil(eventParams, options);\n }\n\n // what outputLogFormatter? that's wrong\n //return new Filter(fil, watches.eth(), formatters.outputLogFormatter);\n return new Filter(fil, watches.eth(), formatter || formatters.outputLogFormatter);\n};\n/*jshint maxparams:3 */\n\nweb3.shh = {};\nweb3.shh.filter = function (fil) {\n return new Filter(fil, watches.shh(), formatters.outputPostFormatter);\n};\nweb3.net = {};\nweb3.db = {};\nweb3.setProvider = function (provider) {\n RequestManager.getInstance().setProvider(provider);\n};\nweb3.reset = function () {\n RequestManager.getInstance().reset();\n};\nweb3.toHex = utils.toHex;\nweb3.toAscii = utils.toAscii;\nweb3.fromAscii = utils.fromAscii;\nweb3.toDecimal = utils.toDecimal;\nweb3.fromDecimal = utils.fromDecimal;\nweb3.toBigNumber = utils.toBigNumber;\nweb3.toWei = utils.toWei;\nweb3.fromWei = utils.fromWei;\nweb3.isAddress = utils.isAddress;\n\n// ADD defaultblock\nObject.defineProperty(web3.eth, 'defaultBlock', {\n get: function () {\n return c.ETH_DEFAULTBLOCK;\n },\n set: function (val) {\n c.ETH_DEFAULTBLOCK = val;\n return c.ETH_DEFAULTBLOCK;\n }\n});\n\n\n/// setups all api methods\nsetupMethods(web3, web3Methods);\nsetupProperties(web3, web3Properties);\nsetupMethods(web3.net, net.methods);\nsetupProperties(web3.net, net.properties);\nsetupMethods(web3.eth, eth.methods);\nsetupProperties(web3.eth, eth.properties);\nsetupMethods(web3.db, db.methods);\nsetupMethods(web3.shh, shh.methods);\n\nmodule.exports = web3;\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 .\n*/\n/** @file contract.js\n * @authors:\n * Marek Kotewicz \n * @date 2014\n */\n\nvar web3 = require('../web3'); \nvar abi = require('../solidity/abi');\nvar utils = require('../utils/utils');\nvar eventImpl = require('./event');\nvar signature = require('./signature');\n\nvar addFunctionRelatedPropertiesToContract = function (contract) {\n \n contract.call = function (options) {\n contract._isTransaction = false;\n contract._options = options;\n return contract;\n };\n\n contract.sendTransaction = function (options) {\n contract._isTransaction = true;\n contract._options = options;\n return contract;\n };\n};\n\nvar addFunctionsToContract = function (contract, desc, address) {\n var inputParser = abi.inputParser(desc);\n var outputParser = abi.outputParser(desc);\n\n // create contract functions\n utils.filterFunctions(desc).forEach(function (method) {\n\n var displayName = utils.extractDisplayName(method.name);\n var typeName = utils.extractTypeName(method.name);\n\n var impl = function () {\n /*jshint maxcomplexity:7 */\n var params = Array.prototype.slice.call(arguments);\n var sign = signature.functionSignatureFromAscii(method.name);\n var parsed = inputParser[displayName][typeName].apply(null, params);\n\n var options = contract._options || {};\n options.to = address;\n options.data = sign + parsed;\n \n var isTransaction = contract._isTransaction === true || (contract._isTransaction !== false && !method.constant);\n var collapse = options.collapse !== false;\n \n // reset\n contract._options = {};\n contract._isTransaction = null;\n\n if (isTransaction) {\n \n // transactions do not have any output, cause we do not know, when they will be processed\n web3.eth.sendTransaction(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 (contract[displayName] === undefined) {\n contract[displayName] = impl;\n }\n\n contract[displayName][typeName] = impl;\n });\n};\n\nvar addEventRelatedPropertiesToContract = function (contract, desc, address) {\n contract.address = address;\n contract._onWatchEventResult = function (data) {\n var matchingEvent = event.getMatchingEvent(utils.filterEvents(desc));\n var parser = eventImpl.outputParser(matchingEvent);\n return parser(data);\n };\n \n Object.defineProperty(contract, 'topics', {\n get: function() {\n return utils.filterEvents(desc).map(function (e) {\n return signature.eventSignatureFromAscii(e.name);\n });\n }\n });\n\n};\n\nvar addEventsToContract = function (contract, desc, address) {\n // create contract events\n utils.filterEvents(desc).forEach(function (e) {\n\n var impl = function () {\n var params = Array.prototype.slice.call(arguments);\n var sign = signature.eventSignatureFromAscii(e.name);\n var event = eventImpl.inputParser(address, sign, e);\n var o = event.apply(null, params);\n var outputFormatter = function (data) {\n var parser = eventImpl.outputParser(e);\n return parser(data);\n };\n return web3.eth.filter(o, undefined, undefined, outputFormatter);\n };\n \n // this property should be used by eth.filter to check if object is an event\n impl._isEvent = true;\n\n var displayName = utils.extractDisplayName(e.name);\n var typeName = utils.extractTypeName(e.name);\n\n if (contract[displayName] === undefined) {\n contract[displayName] = impl;\n }\n\n contract[displayName][typeName] = impl;\n\n });\n};\n\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(abi); // creation of contract prototype\n *\n * var contractInstance = new MyContract('0x0123123121');\n *\n * contractInstance.myMethod('this is test string param for call'); // myMethod call (implicit, default)\n * contractInstance.call().myMethod('this is test string param for call'); // myMethod call (explicit)\n * contractInstance.sendTransaction().myMethod('this is test string param for transact'); // myMethod sendTransaction\n *\n * @param abi - abi json description of the contract, which is being created\n * @returns contract object\n */\nvar contract = function (abi) {\n\n // return prototype\n return Contract.bind(null, abi);\n};\n\nfunction Contract(abi, address) {\n\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 // TODO: we may not want to modify input params, maybe use copy instead?\n abi.forEach(function (method) {\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 result = {};\n addFunctionRelatedPropertiesToContract(result);\n addFunctionsToContract(result, abi, address);\n addEventRelatedPropertiesToContract(result, abi, address);\n addEventsToContract(result, abi, address);\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 .\n*/\n/** @file db.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar Method = require('./method');\n\nvar putString = new Method({\n name: 'putString',\n call: 'db_putString',\n params: 3\n});\n\n\nvar getString = new Method({\n name: 'getString',\n call: 'db_getString',\n params: 2\n});\n\nvar putHex = new Method({\n name: 'putHex',\n call: 'db_putHex',\n params: 3\n});\n\nvar getHex = new Method({\n name: 'getHex',\n call: 'db_getHex',\n params: 2\n});\n\nvar methods = [\n putString, getString, putHex, getHex\n];\n\nmodule.exports = {\n methods: methods\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 .\n*/\n/** \n * @file errors.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\nvar utils = require('../utils/utils');\n\nmodule.exports = {\n InvalidNumberOfParams: new Error('Invalid number of input parameters'),\n InvalidProvider: new Error('Providor not set or invalid'),\n InvalidResponse: function(result){\n var message = 'Invalid JSON RPC response';\n\n if(utils.isObject(result) && result.error && result.error.message) {\n message = result.error.message;\n }\n\n return new Error(message);\n }\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 .\n*/\n/**\n * @file eth.js\n * @author Marek Kotewicz \n * @author Fabian Vogelsteller \n * @date 2015\n */\n\n/**\n * Web3\n * \n * @module web3\n */\n\n/**\n * Eth methods and properties\n *\n * An example method object can look as follows:\n *\n * {\n * name: 'getBlock',\n * call: blockCall,\n * params: 2,\n * outputFormatter: formatters.outputBlockFormatter,\n * inputFormatter: [ // can be a formatter funciton or an array of functions. Where each item in the array will be used for one parameter\n * utils.toHex, // formats paramter 1\n * function(param){ return !!param; } // formats paramter 2\n * ]\n * },\n *\n * @class [web3] eth\n * @constructor\n */\n\n\"use strict\";\n\nvar formatters = require('./formatters');\nvar utils = require('../utils/utils');\nvar Method = require('./method');\nvar Property = require('./property');\n\nvar blockCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? \"eth_getBlockByHash\" : \"eth_getBlockByNumber\";\n};\n\nvar transactionFromBlockCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';\n};\n\nvar uncleCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';\n};\n\nvar getBlockTransactionCountCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';\n};\n\nvar uncleCountCall = function (args) {\n return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';\n};\n\n/// @returns an array of objects describing web3.eth api methods\n\nvar getBalance = new Method({\n name: 'getBalance', \n call: 'eth_getBalance', \n params: 2,\n inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter],\n outputFormatter: formatters.outputBigNumberFormatter\n});\n\nvar getStorageAt = new Method({\n name: 'getStorageAt', \n call: 'eth_getStorageAt', \n params: 3,\n inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]\n});\n\nvar getCode = new Method({\n name: 'getCode',\n call: 'eth_getCode',\n params: 2,\n inputFormatter: [utils.toAddress, formatters.inputDefaultBlockNumberFormatter]\n});\n\nvar getBlock = new Method({\n name: 'getBlock', \n call: blockCall,\n params: 2,\n\tinputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],\n outputFormatter: formatters.outputBlockFormatter\n});\n\nvar getUncle = new Method({\n name: 'getUncle',\n call: uncleCall,\n params: 3,\n\tinputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex, function (val) { return !!val; }],\n outputFormatter: formatters.outputBlockFormatter,\n\n});\n\nvar getCompilers = new Method({\n name: 'getCompilers',\n call: 'eth_getCompilers',\n params: 0\n});\n\nvar getBlockTransactionCount = new Method({\n name: 'getBlockTransactionCount',\n call: getBlockTransactionCountCall,\n params: 1,\n inputFormatter: [formatters.inputBlockNumberFormatter],\n outputFormatter: utils.toDecimal\n});\n\nvar getBlockUncleCount = new Method({\n name: 'getBlockUncleCount',\n call: uncleCountCall,\n params: 1,\n inputFormatter: [formatters.inputBlockNumberFormatter],\n outputFormatter: utils.toDecimal\n});\n\nvar getTransaction = new Method({\n name: 'getTransaction',\n call: 'eth_getTransactionByHash',\n params: 1,\n outputFormatter: formatters.outputTransactionFormatter\n});\n\nvar getTransactionFromBlock = new Method({\n name: 'getTransactionFromBlock',\n call: transactionFromBlockCall,\n params: 2,\n inputFormatter: [utils.toHex, utils.toHex],\n outputFormatter: formatters.outputTransactionFormatter\n});\n\nvar getTransactionCount = new Method({\n name: 'getTransactionCount',\n call: 'eth_getTransactionCount',\n params: 2,\n inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],\n outputFormatter: utils.toDecimal\n});\n\nvar sendTransaction = new Method({\n name: 'sendTransaction',\n call: 'eth_sendTransaction',\n params: 1,\n inputFormatter: [formatters.inputTransactionFormatter]\n});\n\nvar call = new Method({\n name: 'call',\n call: 'eth_call',\n params: 2,\n inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter]\n});\n\nvar compileSolidity = new Method({\n name: 'compile.solidity',\n call: 'eth_compileSolidity',\n params: 1\n});\n\nvar compileLLL = new Method({\n name: 'compile.lll',\n call: 'eth_compileLLL',\n params: 1\n});\n\nvar compileSerpent = new Method({\n name: 'compile.serpent',\n call: 'eth_compileSerpent',\n params: 1\n});\n\nvar flush = new Method({\n name: 'flush',\n call: 'eth_flush',\n params: 0\n});\n\nvar methods = [\n getBalance,\n getStorageAt,\n getCode,\n getBlock,\n getUncle,\n getCompilers,\n getBlockTransactionCount,\n getBlockUncleCount,\n getTransaction,\n getTransactionFromBlock,\n getTransactionCount,\n call,\n sendTransaction,\n compileSolidity,\n compileLLL,\n compileSerpent,\n flush\n];\n\n/// @returns an array of objects describing web3.eth api properties\n\n\n\nvar properties = [\n new Property({\n name: 'coinbase',\n getter: 'eth_coinbase'\n }),\n new Property({\n name: 'mining',\n getter: 'eth_mining'\n }),\n new Property({\n name: 'gasPrice',\n getter: 'eth_gasPrice',\n outputFormatter: formatters.inputNumberFormatter\n }),\n new Property({\n name: 'accounts',\n getter: 'eth_accounts'\n }),\n new Property({\n name: 'blockNumber',\n getter: 'eth_blockNumber',\n outputFormatter: utils.toDecimal\n })\n];\n\nmodule.exports = {\n methods: methods,\n properties: properties\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 .\n*/\n/** @file event.js\n * @authors:\n * Marek Kotewicz \n * @date 2014\n */\n\nvar abi = require('../solidity/abi');\nvar utils = require('../utils/utils');\nvar signature = require('./signature');\n\n/// filter inputs array && returns only indexed (or not) inputs\n/// @param inputs array\n/// @param bool if result should be an array of indexed params on not\n/// @returns array of (not?) indexed params\nvar filterInputs = function (inputs, indexed) {\n return inputs.filter(function (current) {\n return current.indexed === indexed;\n });\n};\n\nvar inputWithName = function (inputs, name) {\n var index = utils.findIndex(inputs, function (input) {\n return input.name === name;\n });\n \n if (index === -1) {\n console.error('indexed param with name ' + name + ' not found');\n return undefined;\n }\n return inputs[index];\n};\n\nvar indexedParamsToTopics = function (event, indexed) {\n // sort keys?\n return Object.keys(indexed).map(function (key) {\n var inputs = [inputWithName(filterInputs(event.inputs, true), key)];\n\n var value = indexed[key];\n if (value instanceof Array) {\n return value.map(function (v) {\n return abi.formatInput(inputs, [v]);\n }); \n }\n return '0x' + abi.formatInput(inputs, [value]);\n });\n};\n\nvar inputParser = function (address, sign, event) {\n \n // valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.filter'\n return function (indexed, options) {\n var o = options || {};\n o.address = address;\n o.topics = [];\n o.topics.push(sign);\n if (indexed) {\n o.topics = o.topics.concat(indexedParamsToTopics(event, indexed));\n }\n return o;\n };\n};\n\nvar getArgumentsObject = function (inputs, indexed, notIndexed) {\n var indexedCopy = indexed.slice();\n var notIndexedCopy = notIndexed.slice();\n return inputs.reduce(function (acc, current) {\n var value;\n if (current.indexed)\n value = indexedCopy.splice(0, 1)[0];\n else\n value = notIndexedCopy.splice(0, 1)[0];\n\n acc[current.name] = value;\n return acc;\n }, {}); \n};\n \nvar outputParser = function (event) {\n \n return function (output) {\n var result = {\n event: utils.extractDisplayName(event.name),\n number: output.number,\n hash: output.hash,\n args: {}\n };\n\n if (!output.topics) {\n return result;\n }\n output.data = output.data || '';\n \n var indexedOutputs = filterInputs(event.inputs, true);\n var indexedData = \"0x\" + output.topics.slice(1, output.topics.length).map(function (topics) { return topics.slice(2); }).join(\"\");\n var indexedRes = abi.formatOutput(indexedOutputs, indexedData);\n\n var notIndexedOutputs = filterInputs(event.inputs, false);\n var notIndexedRes = abi.formatOutput(notIndexedOutputs, output.data);\n\n result.args = getArgumentsObject(event.inputs, indexedRes, notIndexedRes);\n\n return result;\n };\n};\n\nvar getMatchingEvent = function (events, payload) {\n for (var i = 0; i < events.length; i++) {\n var sign = signature.eventSignatureFromAscii(events[i].name); \n if (sign === payload.topics[0]) {\n return events[i];\n }\n }\n return undefined;\n};\n\n\nmodule.exports = {\n inputParser: inputParser,\n outputParser: outputParser,\n getMatchingEvent: getMatchingEvent\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 .\n*/\n/** @file filter.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * Gav Wood \n * @date 2014\n */\n\nvar RequestManager = require('./requestmanager');\nvar formatters = require('./formatters');\nvar utils = require('../utils/utils');\n\n/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones\n/// @param should be string or object\n/// @returns options string or object\nvar getOptions = function (options) {\n\n if (utils.isString(options)) {\n return options;\n } \n\n options = options || {};\n\n // make sure topics, get converted to hex\n options.topics = options.topics || [];\n options.topics = options.topics.map(function(topic){\n return utils.toHex(topic);\n });\n\n // lazy load\n return {\n topics: options.topics,\n to: options.to,\n address: options.address,\n fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),\n toBlock: formatters.inputBlockNumberFormatter(options.toBlock) \n }; \n};\n\nvar Filter = function (options, methods, formatter) {\n var implementation = {};\n methods.forEach(function (method) {\n method.attachToObject(implementation);\n });\n this.options = getOptions(options);\n this.implementation = implementation;\n this.callbacks = [];\n this.formatter = formatter;\n this.filterId = this.implementation.newFilter(this.options);\n};\n\nFilter.prototype.watch = function (callback) {\n this.callbacks.push(callback);\n var self = this;\n\n var onMessage = function (error, messages) {\n if (error) {\n return self.callbacks.forEach(function (callback) {\n callback(error);\n });\n }\n\n messages.forEach(function (message) {\n message = self.formatter ? self.formatter(message) : message;\n self.callbacks.forEach(function (callback) {\n callback(null, message);\n });\n });\n };\n\n RequestManager.getInstance().startPolling({\n method: this.implementation.poll.call,\n params: [this.filterId],\n }, this.filterId, onMessage, this.stopWatching.bind(this));\n};\n\nFilter.prototype.stopWatching = function () {\n RequestManager.getInstance().stopPolling(this.filterId);\n this.implementation.uninstallFilter(this.filterId);\n this.callbacks = [];\n};\n\nFilter.prototype.get = function () {\n var logs = this.implementation.getLogs(this.filterId);\n var self = this;\n return logs.map(function (log) {\n return self.formatter ? self.formatter(log) : log;\n });\n};\n\nmodule.exports = Filter;\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 .\n*/\n/** \n * @file formatters.js\n * @author Marek Kotewicz \n * @author Fabian Vogelsteller \n * @date 2015\n */\n\nvar utils = require('../utils/utils');\nvar config = require('../utils/config');\n\n/**\n * Should the format output to a big number\n *\n * @method outputBigNumberFormatter\n * @param {String|Number|BigNumber}\n * @returns {BigNumber} object\n */\nvar outputBigNumberFormatter = function (number) {\n return utils.toBigNumber(number);\n};\n\nvar isPredefinedBlockNumber = function (blockNumber) {\n return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';\n};\n\nvar inputDefaultBlockNumberFormatter = function (blockNumber) {\n if (blockNumber === undefined) {\n return config.ETH_DEFAULTBLOCK;\n }\n return inputBlockNumberFormatter(blockNumber);\n};\n\nvar inputBlockNumberFormatter = function (blockNumber) {\n if (blockNumber === undefined) {\n return undefined;\n } else if (isPredefinedBlockNumber(blockNumber)) {\n return blockNumber;\n }\n return utils.toHex(blockNumber);\n};\n\n/**\n * Formats the input of a transaction and converts all values to HEX\n *\n * @method inputTransactionFormatter\n * @param {Object} transaction options\n * @returns object\n*/\nvar inputTransactionFormatter = function (options){\n\n // make code -> data\n if (options.code) {\n options.data = options.code;\n delete options.code;\n }\n\n ['gasPrice', 'gas', 'value'].filter(function (key) {\n return options[key] !== undefined;\n }).forEach(function(key){\n options[key] = utils.fromDecimal(options[key]);\n });\n\n return options; \n};\n\n/**\n * Formats the output of a transaction to its proper values\n * \n * @method outputTransactionFormatter\n * @param {Object} transaction\n * @returns {Object} transaction\n*/\nvar outputTransactionFormatter = function (tx){\n tx.blockNumber = utils.toDecimal(tx.blockNumber);\n tx.transactionIndex = utils.toDecimal(tx.transactionIndex);\n tx.gas = utils.toDecimal(tx.gas);\n tx.gasPrice = utils.toBigNumber(tx.gasPrice);\n tx.value = utils.toBigNumber(tx.value);\n return tx;\n};\n\n/**\n * Formats the output of a block to its proper values\n *\n * @method outputBlockFormatter\n * @param {Object} block object \n * @returns {Object} block object\n*/\nvar outputBlockFormatter = function(block) {\n\n // transform to number\n block.gasLimit = utils.toDecimal(block.gasLimit);\n block.gasUsed = utils.toDecimal(block.gasUsed);\n block.size = utils.toDecimal(block.size);\n block.timestamp = utils.toDecimal(block.timestamp);\n block.number = utils.toDecimal(block.number);\n\n block.minGasPrice = utils.toBigNumber(block.minGasPrice);\n block.difficulty = utils.toBigNumber(block.difficulty);\n block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);\n\n if (utils.isArray(block.transactions)) {\n block.transactions.forEach(function(item){\n if(!utils.isString(item))\n return outputTransactionFormatter(item);\n });\n }\n\n return block;\n};\n\n/**\n * Formats the output of a log\n * \n * @method outputLogFormatter\n * @param {Object} log object\n * @returns {Object} log\n*/\nvar outputLogFormatter = function(log) {\n if (log === null) { // 'pending' && 'latest' filters are nulls\n return null;\n }\n\n log.blockNumber = utils.toDecimal(log.blockNumber);\n log.transactionIndex = utils.toDecimal(log.transactionIndex);\n log.logIndex = utils.toDecimal(log.logIndex);\n\n return log;\n};\n\n/**\n * Formats the input of a whisper post and converts all values to HEX\n *\n * @method inputPostFormatter\n * @param {Object} transaction object\n * @returns {Object}\n*/\nvar inputPostFormatter = function(post) {\n\n post.payload = utils.toHex(post.payload);\n post.ttl = utils.fromDecimal(post.ttl);\n post.priority = utils.fromDecimal(post.priority);\n\n if(!utils.isArray(post.topics)) {\n post.topics = [post.topics];\n }\n\n // format the following options\n post.topics = post.topics.map(function(topic){\n return utils.fromAscii(topic);\n });\n\n return post; \n};\n\n/**\n * Formats the output of a received post message\n *\n * @method outputPostFormatter\n * @param {Object}\n * @returns {Object}\n */\nvar outputPostFormatter = function(post){\n\n post.expiry = utils.toDecimal(post.expiry);\n post.sent = utils.toDecimal(post.sent);\n post.ttl = utils.toDecimal(post.ttl);\n post.workProved = utils.toDecimal(post.workProved);\n post.payloadRaw = post.payload;\n post.payload = utils.toAscii(post.payload);\n\n if (utils.isJson(post.payload)) {\n post.payload = JSON.parse(post.payload);\n }\n\n // format the following options\n post.topics = post.topics.map(function(topic){\n return utils.toAscii(topic);\n });\n\n return post;\n};\n\nmodule.exports = {\n inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,\n inputBlockNumberFormatter: inputBlockNumberFormatter,\n inputTransactionFormatter: inputTransactionFormatter,\n inputPostFormatter: inputPostFormatter,\n outputBigNumberFormatter: outputBigNumberFormatter,\n outputTransactionFormatter: outputTransactionFormatter,\n outputBlockFormatter: outputBlockFormatter,\n outputLogFormatter: outputLogFormatter,\n outputPostFormatter: outputPostFormatter\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 .\n*/\n/** @file httpprovider.js\n * @authors:\n * Marek Kotewicz \n * Marian Oancea \n * Fabian Vogelsteller \n * @date 2014\n */\n\n\"use strict\";\n\nvar XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line\n\nvar HttpProvider = function (host) {\n this.host = host || 'http://localhost:8080';\n};\n\nHttpProvider.prototype.send = function (payload) {\n var request = new XMLHttpRequest();\n\n request.open('POST', this.host, false);\n request.send(JSON.stringify(payload));\n\n // check request.status\n // TODO: throw an error here! it cannot silently fail!!!\n //if (request.status !== 200) {\n //return;\n //}\n return JSON.parse(request.responseText);\n};\n\nHttpProvider.prototype.sendAsync = function (payload, callback) {\n var request = new XMLHttpRequest();\n request.onreadystatechange = function() {\n if (request.readyState === 4) {\n // TODO: handle the error properly here!!!\n callback(null, JSON.parse(request.responseText));\n }\n };\n\n request.open('POST', this.host, true);\n request.send(JSON.stringify(payload));\n};\n\nmodule.exports = HttpProvider;\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 .\n*/\n/** @file jsonrpc.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar Jsonrpc = function () {\n // singleton pattern\n if (arguments.callee._singletonInstance) {\n return arguments.callee._singletonInstance;\n }\n arguments.callee._singletonInstance = this;\n\n this.messageId = 1;\n};\n\n/**\n * @return {Jsonrpc} singleton\n */\nJsonrpc.getInstance = function () {\n var instance = new Jsonrpc();\n return instance;\n};\n\n/**\n * Should be called to valid json create payload object\n *\n * @method toPayload\n * @param {Function} method of jsonrpc call, required\n * @param {Array} params, an array of method params, optional\n * @returns {Object} valid jsonrpc payload object\n */\nJsonrpc.prototype.toPayload = function (method, params) {\n if (!method)\n console.error('jsonrpc method should be specified!');\n\n return {\n jsonrpc: '2.0',\n method: method,\n params: params || [],\n id: this.messageId++\n };\n};\n\n/**\n * Should be called to check if jsonrpc response is valid\n *\n * @method isValidResponse\n * @param {Object}\n * @returns {Boolean} true if response is valid, otherwise false\n */\nJsonrpc.prototype.isValidResponse = function (response) {\n return !!response &&\n !response.error &&\n response.jsonrpc === '2.0' &&\n typeof response.id === 'number' &&\n response.result !== undefined; // only undefined is not valid json object\n};\n\n/**\n * Should be called to create batch payload object\n *\n * @method toBatchPayload\n * @param {Array} messages, an array of objects with method (required) and params (optional) fields\n * @returns {Array} batch payload\n */\nJsonrpc.prototype.toBatchPayload = function (messages) {\n var self = this;\n return messages.map(function (message) {\n return self.toPayload(message.method, message.params);\n });\n};\n\nmodule.exports = Jsonrpc;\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 .\n*/\n/**\n * @file method.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\nvar RequestManager = require('./requestmanager');\nvar utils = require('../utils/utils');\nvar errors = require('./errors');\n\nvar Method = function (options) {\n this.name = options.name;\n this.call = options.call;\n this.params = options.params || 0;\n this.inputFormatter = options.inputFormatter;\n this.outputFormatter = options.outputFormatter;\n};\n\n/**\n * Should be used to determine name of the jsonrpc method based on arguments\n *\n * @method getCall\n * @param {Array} arguments\n * @return {String} name of jsonrpc method\n */\nMethod.prototype.getCall = function (args) {\n return utils.isFunction(this.call) ? this.call(args) : this.call;\n};\n\n/**\n * Should be used to extract callback from array of arguments. Modifies input param\n *\n * @method extractCallback\n * @param {Array} arguments\n * @return {Function|Null} callback, if exists\n */\nMethod.prototype.extractCallback = function (args) {\n if (utils.isFunction(args[args.length - 1])) {\n return args.pop(); // modify the args array!\n }\n return null;\n};\n\n/**\n * Should be called to check if the number of arguments is correct\n * \n * @method validateArgs\n * @param {Array} arguments\n * @throws {Error} if it is not\n */\nMethod.prototype.validateArgs = function (args) {\n if (args.length !== this.params) {\n throw errors.InvalidNumberOfParams;\n }\n};\n\n/**\n * Should be called to format input args of method\n * \n * @method formatInput\n * @param {Array}\n * @return {Array}\n */\nMethod.prototype.formatInput = function (args) {\n if (!this.inputFormatter) {\n return args;\n }\n\n return this.inputFormatter.map(function (formatter, index) {\n return formatter ? formatter(args[index]) : args[index];\n });\n};\n\n/**\n * Should be called to format output(result) of method\n *\n * @method formatOutput\n * @param {Object}\n * @return {Object}\n */\nMethod.prototype.formatOutput = function (result) {\n return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;\n};\n\n/**\n * Should attach function to method\n * \n * @method attachToObject\n * @param {Object}\n * @param {Function}\n */\nMethod.prototype.attachToObject = function (obj) {\n var func = this.send.bind(this);\n func.call = this.call; // that's ugly. filter.js uses it\n var name = this.name.split('.');\n if (name.length > 1) {\n obj[name[0]] = obj[name[0]] || {};\n obj[name[0]][name[1]] = func;\n } else {\n obj[name[0]] = func; \n }\n};\n\n/**\n * Should create payload from given input args\n *\n * @method toPayload\n * @param {Array} args\n * @return {Object}\n */\nMethod.prototype.toPayload = function (args) {\n var call = this.getCall(args);\n var callback = this.extractCallback(args);\n var params = this.formatInput(args);\n this.validateArgs(params);\n\n return {\n method: call,\n params: params,\n callback: callback\n };\n};\n\n/**\n * Should send request to the API\n *\n * @method send\n * @param list of params\n * @return result\n */\nMethod.prototype.send = function () {\n var payload = this.toPayload(Array.prototype.slice.call(arguments));\n if (payload.callback) {\n var self = this;\n return RequestManager.getInstance().sendAsync(payload, function (err, result) {\n payload.callback(null, self.formatOutput(result));\n });\n }\n return this.formatOutput(RequestManager.getInstance().send(payload));\n};\n\nmodule.exports = Method;\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 .\n*/\n/** @file eth.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar utils = require('../utils/utils');\nvar Property = require('./property');\n\n/// @returns an array of objects describing web3.eth api methods\nvar methods = [\n];\n\n/// @returns an array of objects describing web3.eth api properties\nvar properties = [\n new Property({\n name: 'listening',\n getter: 'net_listening'\n }),\n new Property({\n name: 'peerCount',\n getter: 'net_peerCount',\n outputFormatter: utils.toDecimal\n })\n];\n\n\nmodule.exports = {\n methods: methods,\n properties: properties\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 .\n*/\n/**\n * @file property.js\n * @author Fabian Vogelsteller \n * @author Marek Kotewicz \n * @date 2015\n */\n\nvar RequestManager = require('./requestmanager');\n\nvar Property = function (options) {\n this.name = options.name;\n this.getter = options.getter;\n this.setter = options.setter;\n this.outputFormatter = options.outputFormatter;\n this.inputFormatter = options.inputFormatter;\n};\n\n/**\n * Should be called to format input args of method\n * \n * @method formatInput\n * @param {Array}\n * @return {Array}\n */\nProperty.prototype.formatInput = function (arg) {\n return this.inputFormatter ? this.inputFormatter(arg) : arg;\n};\n\n/**\n * Should be called to format output(result) of method\n *\n * @method formatOutput\n * @param {Object}\n * @return {Object}\n */\nProperty.prototype.formatOutput = function (result) {\n return this.outputFormatter && result !== null ? this.outputFormatter(result) : result;\n};\n\n/**\n * Should attach function to method\n * \n * @method attachToObject\n * @param {Object}\n * @param {Function}\n */\nProperty.prototype.attachToObject = function (obj) {\n var proto = {\n get: this.get.bind(this),\n set: this.set.bind(this)\n };\n\n var name = this.name.split('.');\n if (name.length > 1) {\n obj[name[0]] = obj[name[0]] || {};\n Object.defineProperty(obj[name[0]], name[1], proto); \n } else {\n Object.defineProperty(obj, name[0], proto);\n }\n};\n\n/**\n * Should be used to get value of the property\n *\n * @method get\n * @return {Object} value of the property\n */\nProperty.prototype.get = function () {\n return this.formatOutput(RequestManager.getInstance().send({\n method: this.getter\n }));\n};\n\n/**\n * Should be used to set value of the property\n *\n * @method set\n * @param {Object} new value of the property\n */\nProperty.prototype.set = function (value) {\n return RequestManager.getInstance().send({\n method: this.setter,\n params: [this.formatInput(value)]\n });\n};\n\nmodule.exports = Property;\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 .\n*/\n/** @file qtsync.js\n * @authors:\n * Marek Kotewicz \n * Marian Oancea \n * @date 2014\n */\n\nvar QtSyncProvider = function () {\n};\n\nQtSyncProvider.prototype.send = function (payload) {\n var result = navigator.qt.callMethod(JSON.stringify(payload));\n return JSON.parse(result);\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 .\n*/\n/** \n * @file requestmanager.js\n * @author Jeffrey Wilcke \n * @author Marek Kotewicz \n * @author Marian Oancea \n * @author Fabian Vogelsteller \n * @author Gav Wood \n * @date 2014\n */\n\nvar Jsonrpc = require('./jsonrpc');\nvar utils = require('../utils/utils');\nvar c = require('../utils/config');\nvar errors = require('./errors');\n\n/**\n * It's responsible for passing messages to providers\n * It's also responsible for polling the ethereum node for incoming messages\n * Default poll timeout is 1 second\n * Singleton\n */\nvar RequestManager = function (provider) {\n // singleton pattern\n if (arguments.callee._singletonInstance) {\n return arguments.callee._singletonInstance;\n }\n arguments.callee._singletonInstance = this;\n\n this.provider = provider;\n this.polls = [];\n this.timeout = null;\n this.poll();\n};\n\n/**\n * @return {RequestManager} singleton\n */\nRequestManager.getInstance = function () {\n var instance = new RequestManager();\n return instance;\n};\n\n/**\n * Should be used to synchronously send request\n *\n * @method send\n * @param {Object} data\n * @return {Object}\n */\nRequestManager.prototype.send = function (data) {\n if (!this.provider) {\n console.error(errors.InvalidProvider);\n return null;\n }\n\n var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);\n var result = this.provider.send(payload);\n\n if (!Jsonrpc.getInstance().isValidResponse(result)) {\n throw errors.InvalidResponse(result);\n }\n\n return result.result;\n};\n\n/**\n * Should be used to asynchronously send request\n *\n * @method sendAsync\n * @param {Object} data\n * @param {Function} callback\n */\nRequestManager.prototype.sendAsync = function (data, callback) {\n if (!this.provider) {\n return callback(errors.InvalidProvider);\n }\n\n var payload = Jsonrpc.getInstance().toPayload(data.method, data.params);\n this.provider.sendAsync(payload, function (err, result) {\n if (err) {\n return callback(err);\n }\n \n if (!Jsonrpc.getInstance().isValidResponse(result)) {\n return callback(errors.InvalidResponse(result));\n }\n\n callback(null, result.result);\n });\n};\n\n/**\n * Should be used to set provider of request manager\n *\n * @method setProvider\n * @param {Object}\n */\nRequestManager.prototype.setProvider = function (p) {\n this.provider = p;\n};\n\n/*jshint maxparams:4 */\n\n/**\n * Should be used to start polling\n *\n * @method startPolling\n * @param {Object} data\n * @param {Number} pollId\n * @param {Function} callback\n * @param {Function} uninstall\n *\n * @todo cleanup number of params\n */\nRequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {\n this.polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});\n};\n/*jshint maxparams:3 */\n\n/**\n * Should be used to stop polling for filter with given id\n *\n * @method stopPolling\n * @param {Number} pollId\n */\nRequestManager.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\n/**\n * Should be called to reset polling mechanism of request manager\n *\n * @method reset\n */\nRequestManager.prototype.reset = function () {\n this.polls.forEach(function (poll) {\n poll.uninstall(poll.id); \n });\n this.polls = [];\n\n if (this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = null;\n }\n this.poll();\n};\n\n/**\n * Should be called to poll for changes on filter with given id\n *\n * @method poll\n */\nRequestManager.prototype.poll = function () {\n this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);\n\n if (!this.polls.length) {\n return;\n }\n\n if (!this.provider) {\n console.error(errors.InvalidProvider);\n return;\n }\n\n var payload = Jsonrpc.getInstance().toBatchPayload(this.polls.map(function (data) {\n return data.data;\n }));\n\n var self = this;\n this.provider.sendAsync(payload, function (error, results) {\n // TODO: console log?\n if (error) {\n return;\n }\n \n if (!utils.isArray(results)) {\n throw errors.InvalidResponse(results);\n }\n\n results.map(function (result, index) {\n result.callback = self.polls[index].callback;\n return result;\n }).filter(function (result) {\n var valid = Jsonrpc.getInstance().isValidResponse(result);\n if (!valid) {\n result.callback(errors.InvalidResponse(result));\n }\n return valid;\n }).filter(function (result) {\n return utils.isArray(result.result) && result.result.length > 0;\n }).forEach(function (result) {\n result.callback(null, result.result);\n });\n });\n};\n\nmodule.exports = RequestManager;\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 .\n*/\n/** @file shh.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar Method = require('./method');\nvar formatters = require('./formatters');\n\nvar post = new Method({\n name: 'post', \n call: 'shh_post', \n params: 1,\n inputFormatter: formatters.inputPostFormatter\n});\n\nvar newIdentity = new Method({\n name: 'newIdentity',\n call: 'shh_newIdentity',\n params: 0\n});\n\nvar hasIdentity = new Method({\n name: 'hasIdentity',\n call: 'shh_hasIdentity',\n params: 1\n});\n\nvar newGroup = new Method({\n name: 'newGroup',\n call: 'shh_newGroup',\n params: 0\n});\n\nvar addToGroup = new Method({\n name: 'addToGroup',\n call: 'shh_addToGroup',\n params: 0\n});\n\nvar methods = [\n post,\n newIdentity,\n hasIdentity,\n newGroup,\n addToGroup\n];\n\nmodule.exports = {\n methods: methods\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 .\n*/\n/** @file signature.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar web3 = require('../web3'); \nvar c = require('../utils/config');\n\n/// @param function name for which we want to get signature\n/// @returns signature of function with given name\nvar functionSignatureFromAscii = function (name) {\n return web3.sha3(web3.fromAscii(name)).slice(0, 2 + c.ETH_SIGNATURE_LENGTH * 2);\n};\n\n/// @param event name for which we want to get signature\n/// @returns signature of event with given name\nvar eventSignatureFromAscii = function (name) {\n return web3.sha3(web3.fromAscii(name));\n};\n\nmodule.exports = {\n functionSignatureFromAscii: functionSignatureFromAscii,\n eventSignatureFromAscii: eventSignatureFromAscii\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 .\n*/\n/** @file watches.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar Method = require('./method');\n\n/// @returns an array of objects describing web3.eth.filter api methods\nvar eth = function () {\n var newFilterCall = function (args) {\n return typeof args[0] === 'string' ? 'eth_newBlockFilter' : 'eth_newFilter';\n };\n\n var newFilter = new Method({\n name: 'newFilter',\n call: newFilterCall,\n params: 1\n });\n\n var uninstallFilter = new Method({\n name: 'uninstallFilter',\n call: 'eth_uninstallFilter',\n params: 1\n });\n\n var getLogs = new Method({\n name: 'getLogs',\n call: 'eth_getFilterLogs',\n params: 1\n });\n\n var poll = new Method({\n name: 'poll',\n call: 'eth_getFilterChanges',\n params: 1\n });\n\n return [\n newFilter,\n uninstallFilter,\n getLogs,\n poll\n ];\n};\n\n/// @returns an array of objects describing web3.shh.watch api methods\nvar shh = function () {\n var newFilter = new Method({\n name: 'newFilter',\n call: 'shh_newFilter',\n params: 1\n });\n\n var uninstallFilter = new Method({\n name: 'uninstallFilter',\n call: 'shh_uninstallFilter',\n params: 1\n });\n\n var getLogs = new Method({\n name: 'getLogs',\n call: 'shh_getMessages',\n params: 1\n });\n\n var poll = new Method({\n name: 'poll',\n call: 'shh_getFilterChanges',\n params: 1\n });\n\n return [\n newFilter,\n uninstallFilter,\n getLogs,\n poll\n ];\n};\n\nmodule.exports = {\n eth: eth,\n shh: shh\n};\n\n",
+ "/*! bignumber.js v2.0.0 https://github.com/MikeMcl/bignumber.js/LICENCE */\r\n\r\n;(function (global) {\r\n 'use strict';\r\n\r\n /*\r\n bignumber.js v2.0.0\r\n A JavaScript library for arbitrary-precision arithmetic.\r\n https://github.com/MikeMcl/bignumber.js\r\n Copyright (c) 2014 Michael Mclaughlin \r\n MIT Expat Licence\r\n */\r\n\r\n /*********************************** DEFAULTS ************************************/\r\n\r\n /*\r\n * The default values below must be integers within the inclusive ranges stated.\r\n * Most of these values can be changed at run-time using the BigNumber.config method.\r\n */\r\n\r\n /*\r\n * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP,\r\n * MAX_EXP, and the argument to toExponential, toFixed, toFormat, and toPrecision,\r\n * beyond which an exception is thrown (if ERRORS is true).\r\n */\r\n var MAX = 1E9, // 0 to 1e+9\r\n\r\n // Limit of magnitude of exponent argument to toPower.\r\n MAX_POWER = 1E6, // 1 to 1e+6\r\n\r\n // The maximum number of decimal places for operations involving division.\r\n DECIMAL_PLACES = 20, // 0 to MAX\r\n\r\n /*\r\n * The rounding mode used when rounding to the above decimal places, and when using\r\n * toExponential, toFixed, toFormat and toPrecision, and round (default value).\r\n * UP 0 Away from zero.\r\n * DOWN 1 Towards zero.\r\n * CEIL 2 Towards +Infinity.\r\n * FLOOR 3 Towards -Infinity.\r\n * HALF_UP 4 Towards nearest neighbour. If equidistant, up.\r\n * HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.\r\n * HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.\r\n * HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.\r\n * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.\r\n */\r\n ROUNDING_MODE = 4, // 0 to 8\r\n\r\n // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]\r\n\r\n // The exponent value at and beneath which toString returns exponential notation.\r\n // Number type: -7\r\n TO_EXP_NEG = -7, // 0 to -MAX\r\n\r\n // The exponent value at and above which toString returns exponential notation.\r\n // Number type: 21\r\n TO_EXP_POS = 21, // 0 to MAX\r\n\r\n // RANGE : [MIN_EXP, MAX_EXP]\r\n\r\n // The minimum exponent value, beneath which underflow to zero occurs.\r\n // Number type: -324 (5e-324)\r\n MIN_EXP = -MAX, // -1 to -MAX\r\n\r\n // The maximum exponent value, above which overflow to Infinity occurs.\r\n // Number type: 308 (1.7976931348623157e+308)\r\n MAX_EXP = MAX, // 1 to MAX\r\n\r\n // Whether BigNumber Errors are ever thrown.\r\n // CHANGE parseInt to parseFloat if changing ERRORS to false.\r\n ERRORS = true, // true or false\r\n parse = parseInt, // parseInt or parseFloat\r\n\r\n // Format specification for the BigNumber.prototype.toFormat method.\r\n FORMAT = {\r\n decimalSeparator: '.',\r\n groupSeparator: ',',\r\n groupSize: 3,\r\n secondaryGroupSize: 0,\r\n fractionGroupSeparator: '\\xA0', // non-breaking space\r\n fractionGroupSize: 0\r\n },\r\n\r\n /***********************************************************************************/\r\n\r\n P = BigNumber.prototype,\r\n DIGITS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',\r\n outOfRange,\r\n id = 0,\r\n mathfloor = Math.floor,\r\n isValid = /^-?(\\d+(\\.\\d*)?|\\.\\d+)(e[+-]?\\d+)?$/i,\r\n trim = String.prototype.trim || function () {return this.replace(/^\\s+|\\s+$/g, '')},\r\n BASE = 1e14,\r\n LOG_BASE = 14,\r\n SQRT_BASE = 1e7,\r\n POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],\r\n ONE = new BigNumber(1);\r\n\r\n\r\n // CONSTRUCTOR\r\n\r\n\r\n /*\r\n * The exported function.\r\n * Create and return a new instance of a BigNumber object.\r\n *\r\n * v {number|string|BigNumber} A numeric value.\r\n * [b] {number} The base of v. Integer, 2 to 64 inclusive.\r\n */\r\n function BigNumber( n, b ) {\r\n var d, e, i, isNum, str, valid,\r\n x = this;\r\n\r\n // Enable constructor usage without new.\r\n if ( !( x instanceof BigNumber ) ) return new BigNumber( n, b );\r\n\r\n // Duplicate.\r\n if ( n instanceof BigNumber ) {\r\n\r\n if ( b == null ) {\r\n id = 0;\r\n x['s'] = n['s'];\r\n x['e'] = n['e'];\r\n x['c'] = ( n = n['c'] ) ? n.slice() : n;\r\n return;\r\n }\r\n n += '';\r\n } else if ( isNum = ( str = typeof n ) == 'number' ) {\r\n\r\n // Fast path for integers.\r\n if ( b == null && n === ~~n ) {\r\n x['s'] = 1 / n < 0 ? ( n = -n, -1 ) : 1;\r\n for ( e = id = 0, i = n; i >= 10; i /= 10, e++ );\r\n x['e'] = e;\r\n x['c'] = [n];\r\n return;\r\n }\r\n\r\n // Minus zero?\r\n n = n === 0 && 1 / n < 0 ? '-0' : n + '';\r\n } else if ( str != 'string' ) {\r\n n += '';\r\n }\r\n str = n;\r\n\r\n if ( b == null && isValid.test(str) ) {\r\n\r\n // Determine sign.\r\n x['s'] = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;\r\n\r\n // Either str is not a valid BigNumber or a base has been specified.\r\n } else {\r\n\r\n // Enable exponential notation to be used with base 10 argument.\r\n // Ensure return value is rounded to DECIMAL_PLACES as with other bases.\r\n if ( b == 10 ) {\r\n x = new BigNumber(str);\r\n return rnd( x, DECIMAL_PLACES + x['e'] + 1, ROUNDING_MODE );\r\n }\r\n str = trim.call(str).replace( /^\\+(?!-)/, '' );\r\n x['s'] = str.charCodeAt(0) === 45 ? ( str = str.replace( /^-(?!-)/, '' ), -1 ) : 1;\r\n\r\n if ( b != null ) {\r\n\r\n if ( ( b == ~~b || !ERRORS ) && !( outOfRange = !( b >= 2 && b < 65 ) ) ) {\r\n d = '[' + DIGITS.slice( 0, b = b | 0 ) + ']+';\r\n\r\n // Before non-decimal number validity test and base conversion\r\n // remove the `.` from e.g. '1.', and replace e.g. '.1' with '0.1'.\r\n str = str.replace( /\\.$/, '' ).replace( /^\\./, '0.' );\r\n\r\n // Any number in exponential form will fail due to the e+/-.\r\n if ( valid = new RegExp( '^' + d + '(?:\\\\.' + d + ')?$',\r\n b < 37 ? 'i' : '' ).test(str) ) {\r\n\r\n if (isNum) {\r\n\r\n if ( str.replace( /^0\\.0*|\\./, '' ).length > 15 ) {\r\n\r\n // 'new BigNumber() number type has more than 15 significant digits: {n}'\r\n ifExceptionsThrow( n, 0 );\r\n }\r\n\r\n // Prevent later check for length on converted number.\r\n isNum = !isNum;\r\n }\r\n str = convertBase( str, 10, b, x['s'] );\r\n } else if ( str != 'Infinity' && str != 'NaN' ) {\r\n\r\n // 'new BigNumber() not a base {b} number: {str}'\r\n ifExceptionsThrow( n, 1, b );\r\n n = 'NaN';\r\n }\r\n } else {\r\n\r\n // 'new BigNumber() base not an integer: {b}'\r\n // 'new BigNumber() base out of range: {b}'\r\n ifExceptionsThrow( b, 2 );\r\n\r\n // Ignore base.\r\n valid = isValid.test(str);\r\n }\r\n } else {\r\n valid = isValid.test(str);\r\n }\r\n\r\n if ( !valid ) {\r\n\r\n // Infinity/NaN\r\n x['c'] = x['e'] = null;\r\n\r\n // NaN\r\n if ( str != 'Infinity' ) {\r\n\r\n // No exception on NaN.\r\n // 'new BigNumber() not a number: {n}'\r\n if ( str != 'NaN' ) ifExceptionsThrow( n, 3 );\r\n x['s'] = null;\r\n }\r\n id = 0;\r\n\r\n return;\r\n }\r\n }\r\n\r\n // Decimal point?\r\n if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );\r\n\r\n // Exponential form?\r\n if ( ( i = str.search( /e/i ) ) > 0 ) {\r\n\r\n // Determine exponent.\r\n if ( e < 0 ) e = i;\r\n e += +str.slice( i + 1 );\r\n str = str.substring( 0, i );\r\n } else if ( e < 0 ) {\r\n\r\n // Integer.\r\n e = str.length;\r\n }\r\n\r\n // Determine leading zeros.\r\n for ( i = 0; str.charCodeAt(i) === 48; i++ );\r\n\r\n // Determine trailing zeros.\r\n for ( b = str.length; str.charCodeAt(--b) === 48; );\r\n str = str.slice( i, b + 1 );\r\n\r\n if (str) {\r\n b = str.length;\r\n\r\n // Disallow numbers with over 15 significant digits if number type.\r\n // 'new BigNumber() number type has more than 15 significant digits: {n}'\r\n if ( isNum && b > 15 ) ifExceptionsThrow( n, 0 );\r\n e = e - i - 1;\r\n\r\n // Overflow?\r\n if ( e > MAX_EXP ) {\r\n\r\n // Infinity.\r\n x['c'] = x['e'] = null;\r\n\r\n // Underflow?\r\n } else if ( e < MIN_EXP ) {\r\n\r\n // Zero.\r\n x['c'] = [ x['e'] = 0 ];\r\n } else {\r\n x['e'] = e;\r\n x['c'] = [];\r\n\r\n // Transform base\r\n\r\n // e is the base 10 exponent.\r\n // i is where to slice str to get the first element of the coefficient array.\r\n i = ( e + 1 ) % LOG_BASE;\r\n if ( e < 0 ) i += LOG_BASE;\r\n\r\n // b is str.length.\r\n if ( i < b ) {\r\n if (i) x['c'].push( +str.slice( 0, i ) );\r\n for ( b -= LOG_BASE; i < b; x['c'].push( +str.slice( i, i += LOG_BASE ) ) );\r\n str = str.slice(i);\r\n i = LOG_BASE - str.length;\r\n } else {\r\n i -= b;\r\n }\r\n\r\n for ( ; i--; str += '0' );\r\n x['c'].push( +str );\r\n }\r\n } else {\r\n\r\n // Zero.\r\n x['c'] = [ x['e'] = 0 ];\r\n }\r\n id = 0;\r\n }\r\n\r\n\r\n // CONSTRUCTOR PROPERTIES/METHODS\r\n\r\n\r\n BigNumber['ROUND_UP'] = 0;\r\n BigNumber['ROUND_DOWN'] = 1;\r\n BigNumber['ROUND_CEIL'] = 2;\r\n BigNumber['ROUND_FLOOR'] = 3;\r\n BigNumber['ROUND_HALF_UP'] = 4;\r\n BigNumber['ROUND_HALF_DOWN'] = 5;\r\n BigNumber['ROUND_HALF_EVEN'] = 6;\r\n BigNumber['ROUND_HALF_CEIL'] = 7;\r\n BigNumber['ROUND_HALF_FLOOR'] = 8;\r\n\r\n\r\n /*\r\n * Configure infrequently-changing library-wide settings.\r\n *\r\n * Accept an object or an argument list, with one or many of the following properties or\r\n * parameters respectively:\r\n * [ DECIMAL_PLACES [, ROUNDING_MODE [, EXPONENTIAL_AT [, RANGE [, ERRORS [, FORMAT ]]]]]]\r\n *\r\n * DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.\r\n * ROUNDING_MODE {number} Integer, 0 to 8 inclusive.\r\n * EXPONENTIAL_AT {number|number[]} Integer, -MAX to MAX inclusive or\r\n * [ integer -MAX to 0 incl., 0 to MAX incl. ].\r\n * RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or\r\n * [ integer -MAX to -1 incl., integer 1 to MAX incl. ].\r\n * ERRORS {boolean|number} true, false, 1 or 0.\r\n * FORMAT {object} See BigNumber.prototype.toFormat.\r\n * decimalSeparator {string}\r\n * groupSeparator {string}\r\n * groupSize {number}\r\n * secondaryGroupSize {number}\r\n * fractionGroupSeparator {string}\r\n * fractionGroupSize {number}\r\n *\r\n * The validity of the values assigned to the above FORMAT object properties is not checked.\r\n *\r\n * E.g.\r\n * BigNumber.config(20, 4) is equivalent to\r\n * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })\r\n *\r\n * Ignore properties/parameters set to null or undefined.\r\n * Return an object with the properties current values.\r\n */\r\n BigNumber['config'] = function () {\r\n var v, p,\r\n i = 0,\r\n r = {},\r\n a = arguments,\r\n o = a[0],\r\n c = 'config',\r\n inRange = function ( n, lo, hi ) {\r\n return !( ( outOfRange = n < lo || n > hi ) || parse(n) != n && n !== 0 );\r\n },\r\n has = o && typeof o == 'object'\r\n ? function () {if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null}\r\n : function () {if ( a.length > i ) return ( v = a[i++] ) != null};\r\n\r\n // [DECIMAL_PLACES] {number} Integer, 0 to MAX inclusive.\r\n if ( has( p = 'DECIMAL_PLACES' ) ) {\r\n\r\n if ( inRange( v, 0, MAX ) ) {\r\n DECIMAL_PLACES = v | 0;\r\n } else {\r\n\r\n // 'config() DECIMAL_PLACES not an integer: {v}'\r\n // 'config() DECIMAL_PLACES out of range: {v}'\r\n ifExceptionsThrow( v, p, c );\r\n }\r\n }\r\n r[p] = DECIMAL_PLACES;\r\n\r\n // [ROUNDING_MODE] {number} Integer, 0 to 8 inclusive.\r\n if ( has( p = 'ROUNDING_MODE' ) ) {\r\n\r\n if ( inRange( v, 0, 8 ) ) {\r\n ROUNDING_MODE = v | 0;\r\n } else {\r\n\r\n // 'config() ROUNDING_MODE not an integer: {v}'\r\n // 'config() ROUNDING_MODE out of range: {v}'\r\n ifExceptionsThrow( v, p, c );\r\n }\r\n }\r\n r[p] = ROUNDING_MODE;\r\n\r\n // [EXPONENTIAL_AT] {number|number[]}\r\n // Integer, -MAX to MAX inclusive or [ integer -MAX to 0 inclusive, 0 to MAX inclusive ].\r\n if ( has( p = 'EXPONENTIAL_AT' ) ) {\r\n\r\n if ( inRange( v, -MAX, MAX ) ) {\r\n TO_EXP_NEG = -( TO_EXP_POS = ~~( v < 0 ? -v : +v ) );\r\n } else if ( !outOfRange && v && inRange( v[0], -MAX, 0 ) && inRange( v[1], 0, MAX ) ) {\r\n TO_EXP_NEG = ~~v[0];\r\n TO_EXP_POS = ~~v[1];\r\n } else {\r\n\r\n // 'config() EXPONENTIAL_AT not an integer or not [integer, integer]: {v}'\r\n // 'config() EXPONENTIAL_AT out of range or not [negative, positive: {v}'\r\n ifExceptionsThrow( v, p, c, 1 );\r\n }\r\n }\r\n r[p] = [ TO_EXP_NEG, TO_EXP_POS ];\r\n\r\n // [RANGE][ {number|number[]} Non-zero integer, -MAX to MAX inclusive or\r\n // [ integer -MAX to -1 inclusive, integer 1 to MAX inclusive ].\r\n if ( has( p = 'RANGE' ) ) {\r\n\r\n if ( inRange( v, -MAX, MAX ) && ~~v ) {\r\n MIN_EXP = -( MAX_EXP = ~~( v < 0 ? -v : +v ) );\r\n } else if ( !outOfRange && v && inRange( v[0], -MAX, -1 ) && inRange( v[1], 1, MAX ) ) {\r\n MIN_EXP = ~~v[0];\r\n MAX_EXP = ~~v[1];\r\n } else {\r\n\r\n // 'config() RANGE not a non-zero integer or not [integer, integer]: {v}'\r\n // 'config() RANGE out of range or not [negative, positive: {v}'\r\n ifExceptionsThrow( v, p, c, 1, 1 );\r\n }\r\n }\r\n r[p] = [ MIN_EXP, MAX_EXP ];\r\n\r\n // [ERRORS] {boolean|number} true, false, 1 or 0.\r\n if ( has( p = 'ERRORS' ) ) {\r\n\r\n if ( v === !!v || v === 1 || v === 0 ) {\r\n outOfRange = id = 0;\r\n parse = ( ERRORS = !!v ) ? parseInt : parseFloat;\r\n } else {\r\n\r\n // 'config() ERRORS not a boolean or binary digit: {v}'\r\n ifExceptionsThrow( v, p, c, 0, 0, 1 );\r\n }\r\n }\r\n r[p] = ERRORS;\r\n\r\n // [FORMAT] {object}\r\n if ( has( p = 'FORMAT' ) ) {\r\n\r\n if ( typeof v == 'object' ) {\r\n FORMAT = v;\r\n } else if (ERRORS) {\r\n\r\n // 'config() FORMAT not an object: {v}'\r\n r = new Error( c + '() ' + p + ' not an object: ' + v );\r\n r['name'] = 'BigNumber Error';\r\n throw r;\r\n }\r\n }\r\n r[p] = FORMAT;\r\n\r\n return r;\r\n };\r\n\r\n\r\n // PRIVATE FUNCTIONS\r\n\r\n\r\n /*\r\n * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.\r\n * Called by minus, plus and times.\r\n */\r\n function normalise( bn, c, e ) {\r\n var i = 1,\r\n j = c.length;\r\n\r\n // Remove trailing zeros.\r\n for ( ; !c[--j]; c.pop() );\r\n\r\n // Calculate the base 10 exponent. First get the number of digits of c[0].\r\n for ( j = c[0]; j >= 10; j /= 10, i++ );\r\n\r\n // Overflow?\r\n if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {\r\n\r\n // Infinity.\r\n bn['c'] = bn['e'] = null;\r\n\r\n // Underflow?\r\n } else if ( e < MIN_EXP ) {\r\n\r\n // Zero.\r\n bn['c'] = [ bn['e'] = 0 ];\r\n } else {\r\n bn['e'] = e;\r\n bn['c'] = c;\r\n }\r\n\r\n return bn;\r\n }\r\n\r\n\r\n /*\r\n * Returns the coefficient array as a string of base 10 digits.\r\n */\r\n function coefficientToString(a) {\r\n var s, z,\r\n i = 1,\r\n j = a.length,\r\n r = a[0] + '';\r\n\r\n for ( ; i < j; ) {\r\n s = a[i++] + '';\r\n z = LOG_BASE - s.length;\r\n for ( ; z--; s = '0' + s );\r\n r += s;\r\n }\r\n\r\n // '0'\r\n for ( j = r.length; r.charCodeAt(--j) === 48; );\r\n\r\n return r.slice( 0, j + 1 || 1 );\r\n }\r\n\r\n\r\n /*\r\n * Convert string of baseIn to an array of numbers of baseOut.\r\n * Eg. convertBase('255', 10, 16) returns [15, 15].\r\n * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].\r\n */\r\n function toBaseOut( str, baseIn, baseOut ) {\r\n var j,\r\n arr = [0],\r\n arrL,\r\n i = 0,\r\n strL = str.length;\r\n\r\n for ( ; i < strL; ) {\r\n for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );\r\n arr[ j = 0 ] += DIGITS.indexOf( str.charAt( i++ ) );\r\n\r\n for ( ; j < arr.length; j++ ) {\r\n\r\n if ( arr[j] > baseOut - 1 ) {\r\n if ( arr[j + 1] == null ) arr[j + 1] = 0;\r\n arr[j + 1] += arr[j] / baseOut | 0;\r\n arr[j] %= baseOut;\r\n }\r\n }\r\n }\r\n\r\n return arr.reverse();\r\n }\r\n\r\n /*\r\n * Convert a numeric string of baseIn to a numeric string of baseOut.\r\n */\r\n function convertBase( str, baseOut, baseIn, sign ) {\r\n var d, e, j, r, x, xc, y,\r\n i = str.indexOf( '.' ),\r\n rm = ROUNDING_MODE;\r\n\r\n if ( baseIn < 37 ) str = str.toLowerCase();\r\n\r\n // Non-integer.\r\n if ( i >= 0 ) {\r\n str = str.replace( '.', '' );\r\n y = new BigNumber(baseIn);\r\n x = y['pow']( str.length - i );\r\n\r\n // Convert str as if an integer, then restore the fraction part by dividing the result\r\n // by its base raised to a power. Use toFixed to avoid possible exponential notation.\r\n y['c'] = toBaseOut( x.toFixed(), 10, baseOut );\r\n y['e'] = y['c'].length;\r\n }\r\n\r\n // Convert the number as integer.\r\n xc = toBaseOut( str, baseIn, baseOut );\r\n e = j = xc.length;\r\n\r\n // Remove trailing zeros.\r\n for ( ; xc[--j] == 0; xc.pop() );\r\n if ( !xc[0] ) return '0';\r\n\r\n if ( i < 0 ) {\r\n --e;\r\n } else {\r\n x['c'] = xc;\r\n x['e'] = e;\r\n // sign is needed for correct rounding.\r\n x['s'] = sign;\r\n x = div( x, y, DECIMAL_PLACES, rm, baseOut );\r\n xc = x['c'];\r\n r = x['r'];\r\n e = x['e'];\r\n }\r\n d = e + DECIMAL_PLACES + 1;\r\n\r\n // The rounding digit, i.e. the digit after the digit that may be rounded up.\r\n i = xc[d];\r\n j = baseOut / 2;\r\n r = r || d < 0 || xc[d + 1] != null;\r\n\r\n r = rm < 4\r\n ? ( i != null || r ) && ( rm == 0 || rm == ( x['s'] < 0 ? 3 : 2 ) )\r\n : i > j || i == j &&\r\n ( rm == 4 || r || rm == 6 && xc[d - 1] & 1 || rm == ( x['s'] < 0 ? 8 : 7 ) );\r\n\r\n if ( d < 1 || !xc[0] ) {\r\n xc.length = 1;\r\n j = 0;\r\n\r\n if (r) {\r\n\r\n // 1, 0.1, 0.01, 0.001, 0.0001 etc.\r\n xc[0] = 1;\r\n e = -DECIMAL_PLACES;\r\n } else {\r\n\r\n // Zero.\r\n e = xc[0] = 0;\r\n }\r\n } else {\r\n xc.length = d;\r\n\r\n if (r) {\r\n\r\n // Rounding up may mean the previous digit has to be rounded up and so on.\r\n for ( --baseOut; ++xc[--d] > baseOut; ) {\r\n xc[d] = 0;\r\n\r\n if ( !d ) {\r\n ++e;\r\n xc.unshift(1);\r\n }\r\n }\r\n }\r\n\r\n // Determine trailing zeros.\r\n for ( j = xc.length; !xc[--j]; );\r\n }\r\n\r\n // E.g. [4, 11, 15] becomes 4bf.\r\n for ( i = 0, str = ''; i <= j; str += DIGITS.charAt( xc[i++] ) );\r\n\r\n // Negative exponent?\r\n if ( e < 0 ) {\r\n\r\n // Prepend zeros.\r\n for ( ; ++e; str = '0' + str );\r\n str = '0.' + str;\r\n\r\n // Positive exponent?\r\n } else {\r\n i = str.length;\r\n\r\n // Append zeros.\r\n if ( ++e > i ) {\r\n for ( e -= i; e-- ; str += '0' );\r\n } else if ( e < i ) {\r\n str = str.slice( 0, e ) + '.' + str.slice(e);\r\n }\r\n }\r\n\r\n // No negative numbers: the caller will add the sign.\r\n return str;\r\n }\r\n\r\n\r\n /*\r\n * Perform division in the specified base. Called by div and convertBase.\r\n */\r\n var div = ( function () {\r\n\r\n // Assumes non-zero x and k.\r\n function multiply( x, k, base ) {\r\n var m, temp, xlo, xhi,\r\n carry = 0,\r\n i = x.length,\r\n klo = k % SQRT_BASE,\r\n khi = k / SQRT_BASE | 0;\r\n\r\n for ( x = x.slice(); i--; ) {\r\n xlo = x[i] % SQRT_BASE;\r\n xhi = x[i] / SQRT_BASE | 0;\r\n m = khi * xlo + xhi * klo;\r\n temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;\r\n carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;\r\n x[i] = temp % base;\r\n }\r\n if (carry) x.unshift(carry);\r\n\r\n return x;\r\n }\r\n\r\n function compare( a, b, aL, bL ) {\r\n var i, cmp;\r\n\r\n if ( aL != bL ) {\r\n cmp = aL > bL ? 1 : -1;\r\n } else {\r\n\r\n for ( i = cmp = 0; i < aL; i++ ) {\r\n\r\n if ( a[i] != b[i] ) {\r\n cmp = a[i] > b[i] ? 1 : -1;\r\n break;\r\n }\r\n }\r\n }\r\n return cmp;\r\n }\r\n\r\n function subtract( a, b, aL, base ) {\r\n var i = 0;\r\n\r\n // Subtract b from a.\r\n for ( ; aL--; ) {\r\n a[aL] -= i;\r\n i = a[aL] < b[aL] ? 1 : 0;\r\n a[aL] = i * base + a[aL] - b[aL];\r\n }\r\n\r\n // Remove leading zeros.\r\n for ( ; !a[0] && a.length > 1; a.shift() );\r\n }\r\n\r\n // x: dividend, y: divisor.\r\n return function ( x, y, dp, rm, base ) {\r\n var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,\r\n yL, yz,\r\n s = x['s'] == y['s'] ? 1 : -1,\r\n xc = x['c'],\r\n yc = y['c'];\r\n\r\n // Either NaN, Infinity or 0?\r\n if ( !xc || !xc[0] || !yc || !yc[0] ) {\r\n\r\n return new BigNumber(\r\n\r\n // Return NaN if either NaN, or both Infinity or 0.\r\n !x['s'] || !y['s'] || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :\r\n\r\n // Return +-0 if x is 0 or y is +-Infinity, or return +-Infinity as y is 0.\r\n xc && xc[0] == 0 || !yc ? s * 0 : s / 0\r\n );\r\n }\r\n\r\n q = new BigNumber(s);\r\n qc = q['c'] = [];\r\n e = x['e'] - y['e'];\r\n s = dp + e + 1;\r\n\r\n if ( !base ) {\r\n base = BASE;\r\n\r\n //e = mathfloor( x['e'] / LOG_BASE ) - mathfloor( y['e'] / LOG_BASE );\r\n e = ( xL = x['e'] / LOG_BASE, i = xL | 0, xL > 0 || xL === i ? i : i - 1 ) -\r\n ( yL = y['e'] / LOG_BASE, i = yL | 0, yL > 0 || yL === i ? i : i - 1 );\r\n\r\n s = s / LOG_BASE | 0;\r\n }\r\n\r\n // Result exponent may be one less then the current value of e.\r\n // The coefficients of the BigNumbers from convertBase may have trailing zeros.\r\n for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );\r\n if ( yc[i] > ( xc[i] || 0 ) ) e--;\r\n\r\n if ( s < 0 ) {\r\n qc.push(1);\r\n more = true;\r\n } else {\r\n xL = xc.length;\r\n yL = yc.length;\r\n i = 0;\r\n s += 2;\r\n\r\n /*\r\n // TODO: fast path division when divisor < base\r\n if ( yL == 1 ) {\r\n n = 0;\r\n yc = yc[0];\r\n s++;\r\n // n is the carry.\r\n for ( ; ( i < xL || n ) && s--; i++ ) {\r\n // Can't use this, it will overflow 2^53.\r\n var t = n * base + ( xc[i] || 0 );\r\n qc[i] = mathfloor( t / yc );\r\n n = t % yc;\r\n }\r\n more = n || i < xL;\r\n\r\n // divisor >= base\r\n } else {\r\n */\r\n // Normalise xc and yc so highest order digit of yc is >= base/2\r\n\r\n n = mathfloor( base / ( yc[0] + 1 ) );\r\n\r\n if ( n > 1 ) {\r\n yc = multiply( yc, n, base );\r\n xc = multiply( xc, n, base );\r\n yL = yc.length;\r\n xL = xc.length;\r\n }\r\n\r\n xi = yL;\r\n rem = xc.slice( 0, yL );\r\n remL = rem.length;\r\n\r\n // Add zeros to make remainder as long as divisor.\r\n for ( ; remL < yL; rem[remL++] = 0 );\r\n yz = yc.slice();\r\n yz.unshift(0);\r\n yc0 = yc[0];\r\n if ( yc[1] >= base / 2 ) yc0++;\r\n\r\n do {\r\n n = 0;\r\n\r\n // Compare divisor and remainder.\r\n cmp = compare( yc, rem, yL, remL );\r\n\r\n // If divisor < remainder.\r\n if ( cmp < 0 ) {\r\n\r\n // Calculate trial digit, n.\r\n\r\n rem0 = rem[0];\r\n if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );\r\n\r\n // n is how many times the divisor goes into the current remainder.\r\n n = mathfloor( rem0 / yc0 );\r\n\r\n\r\n // Algorithm:\r\n // 1. product = divisor * trial digit (n)\r\n // 2. if product > remainder: product -= divisor, n--\r\n // 3. remainder -= product\r\n // 4. if product was < remainder at 2:\r\n // 5. compare new remainder and divisor\r\n // 6. If remainder > divisor: remainder -= divisor, n++\r\n\r\n if ( n > 1 ) {\r\n if ( n >= base ) n = base - 1;\r\n\r\n // product = divisor * trial digit.\r\n prod = multiply( yc, n, base );\r\n prodL = prod.length;\r\n remL = rem.length;\r\n\r\n // Compare product and remainder.\r\n cmp = compare( prod, rem, prodL, remL );\r\n\r\n // product > remainder.\r\n if ( cmp == 1 ) {\r\n n--;\r\n\r\n // Subtract divisor from product.\r\n subtract( prod, yL < prodL ? yz : yc, prodL, base );\r\n }\r\n } else {\r\n\r\n // cmp is -1.\r\n // If n is 0, there is no need to compare yc and rem again below,\r\n // so change cmp to 1 to avoid it.\r\n // If n is 1, compare yc and rem again below.\r\n if ( n == 0 ) cmp = n = 1;\r\n prod = yc.slice();\r\n }\r\n\r\n prodL = prod.length;\r\n if ( prodL < remL ) prod.unshift(0);\r\n\r\n // Subtract product from remainder.\r\n subtract( rem, prod, remL, base );\r\n\r\n // If product was < previous remainder.\r\n if ( cmp == -1 ) {\r\n remL = rem.length;\r\n\r\n // Compare divisor and new remainder.\r\n cmp = compare( yc, rem, yL, remL );\r\n\r\n // If divisor < new remainder, subtract divisor from remainder.\r\n if ( cmp < 1 ) {\r\n n++;\r\n\r\n // Subtract divisor from remainder.\r\n subtract( rem, yL < remL ? yz : yc, remL, base );\r\n }\r\n }\r\n remL = rem.length;\r\n } else if ( cmp === 0 ) {\r\n n++;\r\n rem = [0];\r\n } // if cmp === 1, n will be 0\r\n\r\n // Add the next digit, n, to the result array.\r\n qc[i++] = n;\r\n\r\n // Update the remainder.\r\n if ( cmp && rem[0] ) {\r\n rem[remL++] = xc[xi] || 0;\r\n } else {\r\n rem = [ xc[xi] ];\r\n remL = 1;\r\n }\r\n } while ( ( xi++ < xL || rem[0] != null ) && s-- );\r\n\r\n more = rem[0] != null;\r\n //}\r\n\r\n // Leading zero?\r\n if ( !qc[0] ) qc.shift();\r\n }\r\n\r\n if ( base == BASE ) {\r\n\r\n // To calculate q.e, first get the number of digits of qc[0].\r\n for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );\r\n rnd( q, dp + ( q['e'] = i + e * LOG_BASE - 1 ) + 1, rm, more );\r\n\r\n // div is being used for base conversion.\r\n } else {\r\n q['e'] = e;\r\n q['r'] = +more;\r\n }\r\n return q;\r\n };\r\n })();\r\n\r\n\r\n /*\r\n * Return a string representing the value of BigNumber n in normal or exponential notation\r\n * rounded to the specified decimal places or significant digits.\r\n *\r\n * Called by toString (k: 1), toExponential (k: 1), toFixed (k: undefined), toPrecision (k: 2).\r\n * i is the index (with the value in normal notation) of the digit that may be rounded up.\r\n * d is the number of digits required including fraction-part trailing zeros.\r\n * z is the number of zeros to be appended.\r\n */\r\n function format( n, i, k ) {\r\n var d, str, z,\r\n e = ( n = new BigNumber(n) )['e'];\r\n\r\n // i == null when toExponential(no arg), or toString() when x >= toExpPos etc.\r\n if ( i == null ) {\r\n d = 0;\r\n } else {\r\n rnd( n, ++i, ROUNDING_MODE );\r\n\r\n // n['e'] may have changed if the value was rounded up.\r\n d = k ? i : i + n['e'] - e;\r\n e = n['e'];\r\n }\r\n str = coefficientToString( n['c'] );\r\n\r\n // toPrecision returns exponential notation if the number of significant digits specified\r\n // is less than the number of digits necessary to represent the integer part of the value\r\n // in normal notation.\r\n\r\n // Exponential notation.\r\n if ( k == 1 || k == 2 && ( i <= e || e <= TO_EXP_NEG ) ) {\r\n\r\n // Append zeros?\r\n for ( ; str.length < d; str += '0' );\r\n if ( str.length > 1 ) str = str.charAt(0) + '.' + str.slice(1);\r\n str += ( e < 0 ? 'e' : 'e+' ) + e;\r\n\r\n // Fixed point notation.\r\n } else {\r\n k = str.length;\r\n\r\n // Negative exponent?\r\n if ( e < 0 ) {\r\n z = d - k;\r\n\r\n // Prepend zeros.\r\n for ( ; ++e; str = '0' + str );\r\n str = '0.' + str;\r\n\r\n // Positive exponent?\r\n } else {\r\n\r\n if ( ++e > k ) {\r\n z = d - e;\r\n\r\n // Append zeros.\r\n for ( e -= k; e-- ; str += '0' );\r\n if ( z > 0 ) str += '.';\r\n } else {\r\n z = d - k;\r\n\r\n if ( e < k ) {\r\n str = str.slice( 0, e ) + '.' + str.slice(e);\r\n } else if ( z > 0 ) {\r\n str += '.';\r\n }\r\n }\r\n }\r\n\r\n // Append more zeros?\r\n if ( z > 0 ) for ( ; z--; str += '0' );\r\n }\r\n return n['s'] < 0 && n['c'][0] ? '-' + str : str;\r\n }\r\n\r\n\r\n // Assemble error messages. Throw BigNumber Errors.\r\n function ifExceptionsThrow( arg, i, j, isArray, isRange, isErrors) {\r\n\r\n if (ERRORS) {\r\n var error,\r\n method = ['new BigNumber', 'cmp', 'div', 'eq', 'gt', 'gte', 'lt',\r\n 'lte', 'minus', 'mod', 'plus', 'times', 'toFraction', 'divToInt'\r\n ][ id ? id < 0 ? -id : id : 1 / id < 0 ? 1 : 0 ] + '()',\r\n message = outOfRange ? ' out of range' : ' not a' +\r\n ( isRange ? ' non-zero' : 'n' ) + ' integer';\r\n\r\n message = ( [\r\n method + ' number type has more than 15 significant digits',\r\n method + ' not a base ' + j + ' number',\r\n method + ' base' + message,\r\n method + ' not a number' ][i] ||\r\n j + '() ' + i + ( isErrors\r\n ? ' not a boolean or binary digit'\r\n : message + ( isArray\r\n ? ' or not [' + ( outOfRange\r\n ? ' negative, positive'\r\n : ' integer, integer' ) + ' ]'\r\n : '' ) ) ) + ': ' + arg;\r\n\r\n outOfRange = id = 0;\r\n error = new Error(message);\r\n error['name'] = 'BigNumber Error';\r\n throw error;\r\n }\r\n }\r\n\r\n\r\n /*\r\n * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.\r\n */\r\n function rnd( x, sd, rm, r ) {\r\n var d, i, j, k, n, ni, rd, xc,\r\n pows10 = POWS_TEN;\r\n\r\n // if x is not Infinity or NaN...\r\n if ( xc = x['c'] ) {\r\n\r\n // rd: the rounding digit, i.e. the digit after the digit that may be rounded up\r\n // n: a base 1e14 number, the value of the element of array x.c containing rd\r\n // ni: the index of n within x.c\r\n // d: the number of digits of n\r\n // i: what would be the index of rd within n if all the numbers were 14 digits long\r\n // (i.e. they had leading zeros)\r\n // j: if > 0, the actual index of rd within n (if < 0, rd is a leading zero)\r\n out: {\r\n\r\n // Get the number of digits of the first element of xc.\r\n for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );\r\n i = sd - d;\r\n\r\n // If the rounding digit is in the first element of xc...\r\n if ( i < 0 ) {\r\n i += LOG_BASE;\r\n j = sd;\r\n n = xc[ ni = 0 ];\r\n\r\n // Get the rounding digit at index j of n.\r\n rd = n / pows10[ d - j - 1 ] % 10 | 0;\r\n } else {\r\n ni = Math.ceil( ( i + 1 ) / LOG_BASE );\r\n\r\n if ( ni >= xc.length ) {\r\n\r\n if (r) {\r\n\r\n // Needed by sqrt.\r\n for ( ; xc.length <= ni; xc.push(0) );\r\n n = rd = 0;\r\n d = 1;\r\n i %= LOG_BASE;\r\n j = i - LOG_BASE + 1;\r\n } else {\r\n break out;\r\n }\r\n } else {\r\n n = k = xc[ni];\r\n\r\n // Get the number of digits of n.\r\n for ( d = 1; k >= 10; k /= 10, d++ );\r\n\r\n // Get the index of rd within n.\r\n i %= LOG_BASE;\r\n\r\n // Get the index of rd within n, adjusted for leading zeros.\r\n // The number of leading zeros of n is given by LOG_BASE - d.\r\n j = i - LOG_BASE + d;\r\n\r\n // Get the rounding digit at index j of n.\r\n rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;\r\n }\r\n }\r\n\r\n r = r || sd < 0 ||\r\n\r\n // Are there any non-zero digits after the rounding digit?\r\n // The expression n % pows10[ d - j - 1 ] returns all the digits of n to the right\r\n // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.\r\n xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );\r\n\r\n r = rm < 4\r\n ? ( rd || r ) && ( rm == 0 || rm == ( x['s'] < 0 ? 3 : 2 ) )\r\n : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&\r\n\r\n // Check whether the digit to the left of the rounding digit is odd.\r\n ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||\r\n rm == ( x['s'] < 0 ? 8 : 7 ) );\r\n\r\n if ( sd < 1 || !xc[0] ) {\r\n xc.length = 0;\r\n\r\n if (r) {\r\n\r\n // Convert sd to decimal places.\r\n sd -= x['e'] + 1;\r\n\r\n // 1, 0.1, 0.01, 0.001, 0.0001 etc.\r\n xc[0] = pows10[ sd % LOG_BASE ];\r\n x['e'] = -sd || 0;\r\n } else {\r\n\r\n // Zero.\r\n xc[0] = x['e'] = 0;\r\n }\r\n\r\n return x;\r\n }\r\n\r\n // Remove excess digits.\r\n if ( i == 0 ) {\r\n xc.length = ni;\r\n k = 1;\r\n ni--;\r\n } else {\r\n xc.length = ni + 1;\r\n k = pows10[ LOG_BASE - i ];\r\n\r\n // E.g. 56700 becomes 56000 if 7 is the rounding digit.\r\n // j > 0 means i > number of leading zeros of n.\r\n xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;\r\n }\r\n\r\n // Round up?\r\n if (r) {\r\n\r\n for ( ; ; ) {\r\n\r\n // If the digit to be rounded up is in the first element of xc...\r\n if ( ni == 0 ) {\r\n\r\n // i will be the length of xc[0] before k is added.\r\n for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );\r\n j = xc[0] += k;\r\n for ( k = 1; j >= 10; j /= 10, k++ );\r\n\r\n // if i != k the length has increased.\r\n if ( i != k ) {\r\n x['e']++;\r\n if ( xc[0] == BASE ) xc[0] = 1;\r\n }\r\n break;\r\n } else {\r\n xc[ni] += k;\r\n if ( xc[ni] != BASE ) break;\r\n xc[ni--] = 0;\r\n k = 1;\r\n }\r\n }\r\n }\r\n\r\n // Remove trailing zeros.\r\n for ( i = xc.length; xc[--i] === 0; xc.pop() );\r\n }\r\n\r\n // Overflow? Infinity.\r\n if ( x['e'] > MAX_EXP ) {\r\n x['c'] = x['e'] = null;\r\n\r\n // Underflow? Zero.\r\n } else if ( x['e'] < MIN_EXP ) {\r\n x['c'] = [ x['e'] = 0 ];\r\n }\r\n }\r\n\r\n return x;\r\n }\r\n\r\n\r\n // PROTOTYPE/INSTANCE METHODS\r\n\r\n\r\n /*\r\n * Return a new BigNumber whose value is the absolute value of this BigNumber.\r\n */\r\n P['absoluteValue'] = P['abs'] = function () {\r\n var x = new BigNumber(this);\r\n if ( x['s'] < 0 ) x['s'] = 1;\r\n return x;\r\n };\r\n\r\n\r\n /*\r\n * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole number\r\n * in the direction of Infinity.\r\n */\r\n P['ceil'] = function () {\r\n return rnd( new BigNumber(this), this['e'] + 1, 2 );\r\n };\r\n\r\n\r\n /*\r\n * Return\r\n * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),\r\n * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),\r\n * 0 if they have the same value,\r\n * or null if the value of either is NaN.\r\n */\r\n P['comparedTo'] = P['cmp'] = function ( y, b ) {\r\n var a,\r\n x = this,\r\n xc = x['c'],\r\n yc = ( id = -id, y = new BigNumber( y, b ) )['c'],\r\n i = x['s'],\r\n j = y['s'],\r\n k = x['e'],\r\n l = y['e'];\r\n\r\n // Either NaN?\r\n if ( !i || !j ) return null;\r\n\r\n a = xc && !xc[0];\r\n b = yc && !yc[0];\r\n\r\n // Either zero?\r\n if ( a || b ) return a ? b ? 0 : -j : i;\r\n\r\n // Signs differ?\r\n if ( i != j ) return i;\r\n\r\n a = i < 0;\r\n b = k == l;\r\n\r\n // Either Infinity?\r\n if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;\r\n\r\n // Compare exponents.\r\n if ( !b ) return k > l ^ a ? 1 : -1;\r\n i = -1;\r\n j = ( k = xc.length ) < ( l = yc.length ) ? k : l;\r\n\r\n // Compare digit by digit.\r\n for ( ; ++i < j; ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;\r\n\r\n // Compare lengths.\r\n return k == l ? 0 : k > l ^ a ? 1 : -1;\r\n };\r\n\r\n\r\n /*\r\n * Return the number of decimal places of the value of this BigNumber, or null if the value of\r\n * this BigNumber is +-Infinity or NaN.\r\n */\r\n P['decimalPlaces'] = P['dp'] = function () {\r\n var n, v,\r\n c = this['c'];\r\n\r\n if ( !c ) return null;\r\n n = ( ( v = c.length - 1 ) - mathfloor( this['e'] / LOG_BASE ) ) * LOG_BASE;\r\n\r\n // Subtract the number of trailing zeros of the last number.\r\n if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );\r\n if ( n < 0 ) n = 0;\r\n\r\n return n;\r\n };\r\n\r\n\r\n /*\r\n * n / 0 = I\r\n * n / N = N\r\n * n / I = 0\r\n * 0 / n = 0\r\n * 0 / 0 = N\r\n * 0 / N = N\r\n * 0 / I = 0\r\n * N / n = N\r\n * N / 0 = N\r\n * N / N = N\r\n * N / I = N\r\n * I / n = I\r\n * I / 0 = I\r\n * I / N = N\r\n * I / I = N\r\n *\r\n * Return a new BigNumber whose value is the value of this BigNumber divided by the value of\r\n * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.\r\n */\r\n P['dividedBy'] = P['div'] = function ( y, b ) {\r\n id = 2;\r\n return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );\r\n };\r\n\r\n\r\n /*\r\n * Return a new BigNumber whose value is the integer part of dividing the value of this\r\n * BigNumber by the value of BigNumber(y, b).\r\n */\r\n P['dividedToIntegerBy'] = P['divToInt'] = function ( y, b ) {\r\n id = 13;\r\n return div( this, new BigNumber( y, b ), 0, 1 );\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is equal to the value of BigNumber(n, b),\r\n * otherwise returns false.\r\n */\r\n P['equals'] = P['eq'] = function ( n, b ) {\r\n id = 3;\r\n return this['cmp']( n, b ) === 0;\r\n };\r\n\r\n\r\n /*\r\n * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole number\r\n * in the direction of -Infinity.\r\n */\r\n P['floor'] = function () {\r\n return rnd( new BigNumber(this), this['e'] + 1, 3 );\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is greater than the value of BigNumber(n, b),\r\n * otherwise returns false.\r\n */\r\n P['greaterThan'] = P['gt'] = function ( n, b ) {\r\n id = 4;\r\n return this['cmp']( n, b ) > 0;\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is greater than or equal to the value of\r\n * BigNumber(n, b), otherwise returns false.\r\n */\r\n P['greaterThanOrEqualTo'] = P['gte'] = function ( n, b ) {\r\n id = 5;\r\n return ( b = this['cmp']( n, b ) ) == 1 || b === 0;\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is a finite number, otherwise returns false.\r\n */\r\n P['isFinite'] = function () {\r\n return !!this['c'];\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is an integer, otherwise return false.\r\n */\r\n P['isInteger'] = P['isInt'] = function () {\r\n return !!this['c'] && mathfloor( this['e'] / LOG_BASE ) > this['c'].length - 2;\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is NaN, otherwise returns false.\r\n */\r\n P['isNaN'] = function () {\r\n return !this['s'];\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is negative, otherwise returns false.\r\n */\r\n P['isNegative'] = P['isNeg'] = function () {\r\n return this['s'] < 0;\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.\r\n */\r\n P['isZero'] = function () {\r\n return !!this['c'] && this['c'][0] == 0;\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is less than the value of BigNumber(n, b),\r\n * otherwise returns false.\r\n */\r\n P['lessThan'] = P['lt'] = function ( n, b ) {\r\n id = 6;\r\n return this['cmp']( n, b ) < 0;\r\n };\r\n\r\n\r\n /*\r\n * Return true if the value of this BigNumber is less than or equal to the value of\r\n * BigNumber(n, b), otherwise returns false.\r\n */\r\n P['lessThanOrEqualTo'] = P['lte'] = function ( n, b ) {\r\n id = 7;\r\n return ( b = this['cmp']( n, b ) ) == -1 || b === 0;\r\n };\r\n\r\n\r\n /*\r\n * n - 0 = n\r\n * n - N = N\r\n * n - I = -I\r\n * 0 - n = -n\r\n * 0 - 0 = 0\r\n * 0 - N = N\r\n * 0 - I = -I\r\n * N - n = N\r\n * N - 0 = N\r\n * N - N = N\r\n * N - I = N\r\n * I - n = I\r\n * I - 0 = I\r\n * I - N = N\r\n * I - I = N\r\n *\r\n * Return a new BigNumber whose value is the value of this BigNumber minus the value of\r\n * BigNumber(y, b).\r\n */\r\n P['minus'] = function ( y, b ) {\r\n var i, j, t, xLTy,\r\n x = this,\r\n a = x['s'];\r\n\r\n id = 8;\r\n y = new BigNumber( y, b );\r\n b = y['s'];\r\n\r\n // Either NaN?\r\n if ( !a || !b ) return new BigNumber(NaN);\r\n\r\n // Signs differ?\r\n if ( a != b ) {\r\n y['s'] = -b;\r\n return x['plus'](y);\r\n }\r\n\r\n var xe = x['e'] / LOG_BASE,\r\n ye = y['e'] / LOG_BASE,\r\n xc = x['c'],\r\n yc = y['c'];\r\n\r\n if ( !xe || !ye ) {\r\n\r\n // Either Infinity?\r\n if ( !xc || !yc ) return xc ? ( y['s'] = -b, y ) : new BigNumber( yc ? x : NaN );\r\n\r\n // Either zero?\r\n if ( !xc[0] || !yc[0] ) {\r\n\r\n // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.\r\n return yc[0] ? ( y['s'] = -b, y ) : new BigNumber( xc[0] ? x :\r\n\r\n // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity\r\n ROUNDING_MODE == 3 ? -0 : 0 );\r\n }\r\n }\r\n\r\n // Floor xe and ye\r\n i = xe | 0;\r\n xe = xe > 0 || xe === i ? i : i - 1;\r\n i = ye | 0;\r\n ye = ye > 0 || ye === i ? i : i - 1;\r\n xc = xc.slice();\r\n\r\n // Determine which is the bigger number.\r\n if ( a = xe - ye ) {\r\n\r\n if ( xLTy = a < 0 ) {\r\n a = -a, t = xc;\r\n } else {\r\n ye = xe, t = yc;\r\n }\r\n\r\n // Prepend zeros to equalise exponents.\r\n for ( t.reverse(), b = a; b--; t.push(0) );\r\n t.reverse();\r\n } else {\r\n\r\n // Exponents equal. Check digit by digit.\r\n j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;\r\n\r\n for ( a = b = 0; b < j; b++ ) {\r\n\r\n if ( xc[b] != yc[b] ) {\r\n xLTy = xc[b] < yc[b];\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // x < y? Point xc to the array of the bigger number.\r\n if (xLTy) t = xc, xc = yc, yc = t, y['s'] = -y['s'];\r\n\r\n b = ( j = yc.length ) - ( i = xc.length );\r\n\r\n // Append zeros to xc if shorter.\r\n // No need to add zeros to yc if shorter as subtraction only needs to start at yc.length.\r\n if ( b > 0 ) for ( ; b--; xc[i++] = 0 );\r\n b = BASE - 1;\r\n\r\n // Subtract yc from xc.\r\n for ( ; j > a; ) {\r\n\r\n if ( xc[--j] < yc[j] ) {\r\n for ( i = j; i && !xc[--i]; xc[i] = b );\r\n --xc[i];\r\n xc[j] += BASE;\r\n }\r\n xc[j] -= yc[j];\r\n }\r\n\r\n // Remove leading zeros and adjust exponent accordingly.\r\n for ( ; xc[0] == 0; xc.shift(), --ye );\r\n\r\n // Zero?\r\n if ( !xc[0] ) {\r\n\r\n // Following IEEE 754 (2008) 6.3,\r\n // n - n = +0 but n - n = -0 when rounding towards -Infinity.\r\n y['s'] = ROUNDING_MODE == 3 ? -1 : 1;\r\n y['c'] = [ y['e'] = 0 ];\r\n return y;\r\n }\r\n\r\n // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity when neither\r\n // x or y are Infinity.\r\n return normalise( y, xc, ye );\r\n };\r\n\r\n\r\n /*\r\n * n % 0 = N\r\n * n % N = N\r\n * 0 % n = 0\r\n * -0 % n = -0\r\n * 0 % 0 = N\r\n * 0 % N = N\r\n * N % n = N\r\n * N % 0 = N\r\n * N % N = N\r\n *\r\n * Return a new BigNumber whose value is the value of this BigNumber modulo the value of\r\n * BigNumber(y, b).\r\n */\r\n P['modulo'] = P['mod'] = function ( y, b ) {\r\n id = 9;\r\n var x = this,\r\n xc = x['c'],\r\n yc = ( y = new BigNumber( y, b ) )['c'],\r\n xs = x['s'],\r\n ys = y['s'];\r\n\r\n // x or y NaN? y zero? x zero?\r\n b = !xs || !ys || yc && !yc[0];\r\n if ( b || xc && !xc[0] ) return new BigNumber( b ? NaN : x );\r\n\r\n x['s'] = y['s'] = 1;\r\n b = y['cmp'](x) == 1;\r\n x['s'] = xs;\r\n y['s'] = ys;\r\n\r\n return b ? new BigNumber(x) : x['minus']( div( x, y, 0, 1 )['times'](y) );\r\n };\r\n\r\n\r\n /*\r\n * Return a new BigNumber whose value is the value of this BigNumber negated, i.e. multiplied\r\n * by -1.\r\n */\r\n P['negated'] = P['neg'] = function () {\r\n var x = new BigNumber(this);\r\n x['s'] = -x['s'] || null;\r\n return x;\r\n };\r\n\r\n\r\n /*\r\n * n + 0 = n\r\n * n + N = N\r\n * n + I = I\r\n * 0 + n = n\r\n * 0 + 0 = 0\r\n * 0 + N = N\r\n * 0 + I = I\r\n * N + n = N\r\n * N + 0 = N\r\n * N + N = N\r\n * N + I = N\r\n * I + n = I\r\n * I + 0 = I\r\n * I + N = N\r\n * I + I = I\r\n *\r\n * Return a new BigNumber whose value is the value of this BigNumber plus the value of\r\n * BigNumber(y, b).\r\n */\r\n P['plus'] = function ( y, b ) {\r\n var t,\r\n x = this,\r\n a = x['s'];\r\n\r\n id = 10;\r\n y = new BigNumber( y, b );\r\n b = y['s'];\r\n\r\n // Either NaN?\r\n if ( !a || !b ) return new BigNumber(NaN);\r\n\r\n // Signs differ?\r\n if ( a != b ) {\r\n y['s'] = -b;\r\n return x['minus'](y);\r\n }\r\n\r\n var xe = x['e'] / LOG_BASE,\r\n ye = y['e'] / LOG_BASE,\r\n xc = x['c'],\r\n yc = y['c'];\r\n\r\n if ( !xe || !ye ) {\r\n\r\n // Return +-Infinity if either Infinity.\r\n if ( !xc || !yc ) return new BigNumber( a / 0 );\r\n\r\n // Either zero? Return y if y is non-zero, x if x is non-zero, or zero if both are zero.\r\n if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );\r\n }\r\n\r\n // Floor xe and ye\r\n a = xe | 0;\r\n xe = xe > 0 || xe === a ? a : a - 1;\r\n a = ye | 0;\r\n ye = ye > 0 || ye === a ? a : a - 1;\r\n xc = xc.slice();\r\n\r\n // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.\r\n if ( a = xe - ye ) {\r\n if ( a > 0 ) {\r\n ye = xe, t = yc;\r\n } else {\r\n a = -a, t = xc;\r\n }\r\n\r\n for ( t.reverse(); a--; t.push(0) );\r\n t.reverse();\r\n }\r\n a = xc.length;\r\n b = yc.length;\r\n\r\n // Point xc to the longer array, and b to the shorter length.\r\n if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;\r\n\r\n // Only start adding at yc.length - 1 as the further digits of xc can be left as they are.\r\n for ( a = 0; b; ) {\r\n a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;\r\n xc[b] %= BASE;\r\n }\r\n\r\n\r\n if (a) {\r\n xc.unshift(a);\r\n ++ye;\r\n }\r\n\r\n // No need to check for zero, as +x + +y != 0 && -x + -y != 0\r\n // ye = MAX_EXP + 1 possible\r\n return normalise( y, xc, ye );\r\n };\r\n\r\n\r\n /*\r\n * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of dp\r\n * decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if omitted.\r\n *\r\n * [dp] {number} Integer, 0 to MAX inclusive.\r\n * [rm] {number} Integer, 0 to 8 inclusive.\r\n */\r\n P['round'] = function ( dp, rm ) {\r\n\r\n dp = dp == null || ( ( ( outOfRange = dp < 0 || dp > MAX ) || parse(dp) != dp ) &&\r\n\r\n // 'round() decimal places out of range: {dp}'\r\n // 'round() decimal places not an integer: {dp}'\r\n !ifExceptionsThrow( dp, 'decimal places', 'round' ) ) ? 0 : dp | 0;\r\n\r\n // Include '&& rm !== 0' because with Opera -0 == parseFloat(-0) is false.\r\n rm = rm == null || ( ( ( outOfRange = rm < 0 || rm > 8 ) || parse(rm) != rm && rm !== 0 ) &&\r\n\r\n // 'round() mode not an integer: {rm}'\r\n // 'round() mode out of range: {rm}'\r\n !ifExceptionsThrow( rm, 'mode', 'round' ) ) ? ROUNDING_MODE : rm | 0;\r\n\r\n return rnd( new BigNumber(this), dp + this['e'] + 1, rm );\r\n };\r\n\r\n\r\n /*\r\n * sqrt(-n) = N\r\n * sqrt( N) = N\r\n * sqrt(-I) = N\r\n * sqrt( I) = I\r\n * sqrt( 0) = 0\r\n * sqrt(-0) = -0\r\n *\r\n * Return a new BigNumber whose value is the square root of the value of this BigNumber,\r\n * rounded according to DECIMAL_PLACES and ROUNDING_MODE.\r\n */\r\n P['squareRoot'] = P['sqrt'] = function () {\r\n var m, n, r, rep, t,\r\n x = this,\r\n c = x['c'],\r\n s = x['s'],\r\n e = x['e'],\r\n dp = DECIMAL_PLACES + 4,\r\n half = new BigNumber('0.5');\r\n\r\n // Negative/NaN/Infinity/zero?\r\n if ( s !== 1 || !c || !c[0] ) {\r\n return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );\r\n }\r\n\r\n // Initial estimate.\r\n s = Math.sqrt( +x );\r\n\r\n // Math.sqrt underflow/overflow?\r\n // Pass x to Math.sqrt as integer, then adjust the exponent of the result.\r\n if ( s == 0 || s == 1 / 0 ) {\r\n n = coefficientToString(c);\r\n if ( ( n.length + e ) % 2 == 0 ) n += '0';\r\n s = Math.sqrt(n);\r\n e = mathfloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );\r\n\r\n if ( s == 1 / 0 ) {\r\n n = '1e' + e;\r\n } else {\r\n n = s.toExponential();\r\n n = n.slice( 0, n.indexOf('e') + 1 ) + e;\r\n }\r\n r = new BigNumber(n);\r\n } else {\r\n r = new BigNumber( s.toString() );\r\n }\r\n\r\n // Check for zero. r could be zero if MIN_EXP is changed after the this value was created.\r\n // This would cause a division by zero (x/t) and hence Infinity below, which would cause\r\n // coefficientToString to throw.\r\n if ( r['c'][0] ) {\r\n e = r['e'];\r\n s = e + dp;\r\n if ( s < 3 ) s = 0;\r\n\r\n // Newton-Raphson iteration.\r\n for ( ; ; ) {\r\n t = r;\r\n r = half['times']( t['plus']( div( x, t, dp, 1 ) ) );\r\n\r\n if ( coefficientToString( t['c'] ).slice( 0, s ) === ( n =\r\n coefficientToString( r['c'] ) ).slice( 0, s ) ) {\r\n\r\n // The exponent of r may here be one less than the final result exponent,\r\n // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits are\r\n // indexed correctly.\r\n if ( r['e'] < e ) --s;\r\n n = n.slice( s - 3, s + 1 );\r\n\r\n // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are\r\n // 9999 or 4999 (i.e. approaching a rounding boundary) continue the iteration.\r\n if ( n == '9999' || !rep && n == '4999' ) {\r\n\r\n // On the first iteration only, check to see if rounding up gives the exact\r\n // result as the nines may infinitely repeat.\r\n if ( !rep ) {\r\n rnd( t, t['e'] + DECIMAL_PLACES + 2, 0 );\r\n\r\n if ( t['times'](t)['eq'](x) ) {\r\n r = t;\r\n break;\r\n }\r\n }\r\n dp += 4;\r\n s += 4;\r\n rep = 1;\r\n } else {\r\n\r\n // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact result.\r\n // If not, then there are further digits and m will be truthy.\r\n if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {\r\n\r\n // Truncate to the first rounding digit.\r\n rnd( r, r['e'] + DECIMAL_PLACES + 2, 1 );\r\n m = !r['times'](r)['eq'](x);\r\n }\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return rnd( r, r['e'] + DECIMAL_PLACES + 1, ROUNDING_MODE, m );\r\n };\r\n\r\n\r\n /*\r\n * n * 0 = 0\r\n * n * N = N\r\n * n * I = I\r\n * 0 * n = 0\r\n * 0 * 0 = 0\r\n * 0 * N = N\r\n * 0 * I = N\r\n * N * n = N\r\n * N * 0 = N\r\n * N * N = N\r\n * N * I = N\r\n * I * n = I\r\n * I * 0 = N\r\n * I * N = N\r\n * I * I = I\r\n *\r\n * Return a new BigNumber whose value is the value of this BigNumber times the value of\r\n * BigNumber(y, b).\r\n */\r\n P['times'] = function ( y, b ) {\r\n var c, e, k, m, r, xlo, xhi, ylo, yhi,\r\n x = this,\r\n xc = x['c'],\r\n yc = ( id = 11, y = new BigNumber( y, b ) )['c'],\r\n i = x['e'] / LOG_BASE,\r\n j = y['e'] / LOG_BASE,\r\n a = x['s'];\r\n\r\n y['s'] = a == ( b = y['s'] ) ? 1 : -1;\r\n\r\n // Either NaN/Infinity/0?\r\n if ( !i && ( !xc || !xc[0] ) || !j && ( !yc || !yc[0] ) ) {\r\n\r\n // Return NaN if either NaN, or x is 0 and y is Infinity, or y is 0 and x is Infinity.\r\n return new BigNumber( !a || !b || xc && !xc[0] && !yc || yc && !yc[0] && !xc ? NaN\r\n\r\n // Return +-Infinity if either is Infinity. Return +-0 if x or y is 0.\r\n : !xc || !yc ? y['s'] / 0 : y['s'] * 0 );\r\n }\r\n\r\n // e = mathfloor(i) + mathfloor(j);\r\n e = ( e = i | 0, i > 0 || i === e ? e : e - 1) +\r\n ( e = j | 0, j > 0 || j === e ? e : e - 1);\r\n\r\n a = xc.length;\r\n b = yc.length;\r\n\r\n // Ensure xc points to longer array and b to longer length.\r\n if ( a < b ) r = xc, xc = yc, yc = r, j = a, a = b, b = j;\r\n\r\n // Initialise the result array with zeros.\r\n for ( j = a + b, r = []; j--; r.push(0) );\r\n\r\n // Multiply!\r\n for ( i = b; --i >= 0; ) {\r\n c = 0;\r\n j = a + i;\r\n k = a;\r\n ylo = yc[i] % SQRT_BASE;\r\n yhi = yc[i] / SQRT_BASE | 0;\r\n\r\n for ( ; j > i; ) {\r\n xlo = xc[--k] % SQRT_BASE;\r\n xhi = xc[k] / SQRT_BASE | 0;\r\n m = yhi * xlo + xhi * ylo;\r\n xlo = ylo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + r[j] + c;\r\n c = ( xlo / BASE | 0 ) + ( m / SQRT_BASE | 0 ) + yhi * xhi;\r\n r[j--] = xlo % BASE;\r\n }\r\n r[j] = c;\r\n }\r\n\r\n if (c) {\r\n ++e;\r\n } else {\r\n r.shift();\r\n }\r\n\r\n return normalise( y, r, e );\r\n };\r\n\r\n\r\n /*\r\n * Return a string representing the value of this BigNumber in exponential notation to dp fixed\r\n * decimal places and rounded using ROUNDING_MODE if necessary.\r\n *\r\n * [dp] {number} Integer, 0 to MAX inclusive.\r\n */\r\n P['toExponential'] = function (dp) {\r\n var x = this;\r\n\r\n return x['c'] ? format( x, dp == null || ( ( outOfRange = dp < 0 || dp > MAX ) ||\r\n\r\n // Include '&& dp !== 0' because with Opera -0 == parseFloat(-0) is false,\r\n // despite -0 == parseFloat('-0') && 0 == -0 being true.\r\n parse(dp) != dp && dp !== 0 ) &&\r\n\r\n // 'toExponential() decimal places not an integer: {dp}'\r\n // 'toExponential() decimal places out of range: {dp}'\r\n !ifExceptionsThrow( dp, 'decimal places', 'toExponential' )\r\n ? null : dp | 0, 1 ) : x.toString();\r\n };\r\n\r\n\r\n /*\r\n * Return a string representing the value of this BigNumber in normal notation to dp fixed\r\n * decimal places and rounded using ROUNDING_MODE if necessary.\r\n *\r\n * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',\r\n * but e.g. (-0.00001).toFixed(0) is '-0'.\r\n *\r\n * [dp] {number} Integer, 0 to MAX inclusive.\r\n */\r\n P['toFixed'] = function (dp) {\r\n var str,\r\n x = this,\r\n neg = TO_EXP_NEG,\r\n pos = TO_EXP_POS;\r\n\r\n dp = dp == null || ( ( outOfRange = dp < 0 || dp > MAX ) ||\r\n\r\n // 'toFixed() decimal places not an integer: {dp}'\r\n // 'toFixed() decimal places out of range: {dp}'\r\n parse(dp) != dp && dp !== 0 ) && !ifExceptionsThrow( dp, 'decimal places', 'toFixed' )\r\n ? null : x['e'] + ( dp | 0 );\r\n\r\n TO_EXP_NEG = -( TO_EXP_POS = 1 / 0 );\r\n\r\n if ( dp == null || !x['c'] ) {\r\n str = x.toString();\r\n } else {\r\n str = format( x, dp );\r\n\r\n // (-0).toFixed() is '0', but (-0.1).toFixed() is '-0'.\r\n // (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.\r\n if ( x['s'] < 0 && x['c'] ) {\r\n\r\n // As e.g. (-0).toFixed(3), will wrongly be returned as -0.000 from toString.\r\n if ( !x['c'][0] ) {\r\n str = str.replace( '-', '' );\r\n\r\n // As e.g. -0.5 if rounded to -0 will cause toString to omit the minus sign.\r\n } else if ( str.indexOf('-') < 0 ) {\r\n str = '-' + str;\r\n }\r\n }\r\n }\r\n\r\n TO_EXP_NEG = neg;\r\n TO_EXP_POS = pos;\r\n\r\n return str;\r\n };\r\n\r\n\r\n /*\r\n * Return a string representing the value of this BigNumber in fixed-point notation rounded\r\n * using ROUNDING_MODE to dp decimal places, and formatted according to the properties of the\r\n * FORMAT object (see BigNumber.config).\r\n *\r\n * FORMAT = {\r\n * decimalSeparator : '.',\r\n * groupSeparator : ',',\r\n * groupSize : 3,\r\n * secondaryGroupSize : 0,\r\n * fractionGroupSeparator : '\\xA0', // non-breaking space\r\n * fractionGroupSize : 0\r\n * };\r\n *\r\n * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.\r\n * (TODO: If dp is invalid the error message will give toFixed as the offending method.)\r\n */\r\n P['toFormat'] = function (dp) {\r\n var x = this;\r\n\r\n if ( !x['c'] ) return x.toString();\r\n\r\n var i,\r\n isNeg = x['s'] < 0,\r\n groupSeparator = FORMAT['groupSeparator'],\r\n g1 = +FORMAT['groupSize'],\r\n g2 = +FORMAT['secondaryGroupSize'],\r\n arr = x.toFixed(dp).split('.'),\r\n intPart = arr[0],\r\n fractionPart = arr[1],\r\n intDigits = isNeg ? intPart.slice(1) : intPart,\r\n len = intDigits.length;\r\n\r\n if (g2) i = g1, g1 = g2, g2 = i, len -= i;\r\n\r\n if ( g1 > 0 && len > 0 ) {\r\n i = len % g1 || g1;\r\n intPart = intDigits.substr( 0, i );\r\n for ( ; i < len; i += g1 ) intPart += groupSeparator + intDigits.substr( i, g1 );\r\n if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);\r\n if (isNeg) intPart = '-' + intPart;\r\n }\r\n\r\n return fractionPart\r\n ? intPart + FORMAT['decimalSeparator'] + ( ( g2 = +FORMAT['fractionGroupSize'] )\r\n ? fractionPart.replace( new RegExp( '\\\\d{' + g2 + '}\\\\B', 'g' ),\r\n '$&' + FORMAT['fractionGroupSeparator'] )\r\n : fractionPart )\r\n : intPart;\r\n };\r\n\r\n\r\n /*\r\n * Return a string array representing the value of this BigNumber as a simple fraction with an\r\n * integer numerator and an integer denominator. The denominator will be a positive non-zero\r\n * value less than or equal to the specified maximum denominator. If a maximum denominator is\r\n * not specified, the denominator will be the lowest value necessary to represent the number\r\n * exactly.\r\n *\r\n * [maxD] {number|string|BigNumber} Integer >= 1 and < Infinity.\r\n */\r\n P['toFraction'] = function (maxD) {\r\n var arr, d0, d2, e, exp, n, n0, q, s,\r\n n1 = d0 = new BigNumber(ONE),\r\n d1 = n0 = new BigNumber(ONE),\r\n x = this,\r\n xc = x['c'],\r\n d = new BigNumber(ONE);\r\n\r\n // NaN, Infinity.\r\n if ( !xc ) return x.toString();\r\n s = coefficientToString(xc);\r\n\r\n // Initial denominator.\r\n e = d['e'] = s.length - x['e'] - 1;\r\n d['c'][0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];\r\n\r\n // If max denominator is undefined or null, or NaN...\r\n if ( maxD == null || ( !( id = 12, n = new BigNumber(maxD) )['s'] ||\r\n\r\n // or less than 1, or Infinity...\r\n ( outOfRange = n['cmp'](n1) < 0 || !n['c'] ) ||\r\n\r\n // or not an integer...\r\n ( ERRORS && mathfloor( n['e'] / LOG_BASE ) < n['c'].length - 1 ) ) &&\r\n\r\n // 'toFraction() max denominator not an integer: {maxD}'\r\n // 'toFraction() max denominator out of range: {maxD}'\r\n !ifExceptionsThrow( maxD, 'max denominator', 'toFraction' ) ||\r\n\r\n // or greater than the max denominator needed to specify the value exactly...\r\n ( maxD = n )['cmp'](d) > 0 ) {\r\n\r\n // d is e.g. 10, 100, 1000, 10000... , n1 is 1.\r\n maxD = e > 0 ? d : n1;\r\n }\r\n\r\n exp = MAX_EXP;\r\n MAX_EXP = 1 / 0;\r\n n = new BigNumber(s);\r\n\r\n // n0 = d1 = 0\r\n n0['c'][0] = 0;\r\n\r\n for ( ; ; ) {\r\n q = div( n, d, 0, 1 );\r\n d2 = d0['plus']( q['times'](d1) );\r\n if ( d2['cmp'](maxD) == 1 ) break;\r\n d0 = d1;\r\n d1 = d2;\r\n n1 = n0['plus']( q['times']( d2 = n1 ) );\r\n n0 = d2;\r\n d = n['minus']( q['times']( d2 = d ) );\r\n n = d2;\r\n }\r\n\r\n d2 = div( maxD['minus'](d0), d1, 0, 1 );\r\n n0 = n0['plus']( d2['times'](n1) );\r\n d0 = d0['plus']( d2['times'](d1) );\r\n n0['s'] = n1['s'] = x['s'];\r\n e *= 2;\r\n\r\n // Determine which fraction is closer to x, n0/d0 or n1/d1\r\n arr = div( n1, d1, e, ROUNDING_MODE )['minus'](x)['abs']()['cmp'](\r\n div( n0, d0, e, ROUNDING_MODE )['minus'](x)['abs']() ) < 1\r\n ? [ n1.toString(), d1.toString() ]\r\n : [ n0.toString(), d0.toString() ];\r\n\r\n MAX_EXP = exp;\r\n\r\n return arr;\r\n };\r\n\r\n\r\n /*\r\n * Return the value of this BigNumber converted to a number primitive.\r\n */\r\n P['toNumber'] = function () {\r\n var x = this;\r\n\r\n // Ensure zero has correct sign.\r\n return +x || ( x['s'] ? 0 * x['s'] : NaN );\r\n };\r\n\r\n\r\n /*\r\n * Return a BigNumber whose value is the value of this BigNumber raised to the power e.\r\n * If e is negative round according to DECIMAL_PLACES and ROUNDING_MODE.\r\n *\r\n * e {number} Integer, -MAX_POWER to MAX_POWER inclusive.\r\n */\r\n P['toPower'] = P['pow'] = function (e) {\r\n\r\n // e to integer, avoiding NaN or Infinity becoming 0.\r\n var i = e * 0 == 0 ? ~~e : e,\r\n x = new BigNumber(this),\r\n y = new BigNumber(ONE);\r\n\r\n // Pass +-Infinity for out of range exponents.\r\n if ( ( ( ( outOfRange = e < -MAX_POWER || e > MAX_POWER ) && (i = e * 1 / 0) ) ||\r\n\r\n // Any exponent that fails the parse becomes NaN.\r\n // Include 'e !== 0' because on Opera -0 == parseFloat(-0) is false, despite\r\n // -0 === parseFloat(-0) && -0 == parseFloat('-0') evaluating true.\r\n parse(e) != e && e !== 0 && !(i = NaN) ) &&\r\n\r\n // 'pow() exponent not an integer: {e}'\r\n // 'pow() exponent out of range: {e}'\r\n // Pass zero to Math.pow, as any value to the power zero is 1.\r\n !ifExceptionsThrow( e, 'exponent', 'pow' ) || !i ) {\r\n\r\n // i is +-Infinity, NaN or 0.\r\n return new BigNumber( Math.pow( +x, i ) );\r\n }\r\n i = i < 0 ? -i : i;\r\n\r\n for ( ; ; ) {\r\n if ( i & 1 ) y = y['times'](x);\r\n i >>= 1;\r\n if ( !i ) break;\r\n x = x['times'](x);\r\n }\r\n\r\n return e < 0 ? ONE['div'](y) : y;\r\n };\r\n\r\n\r\n /*\r\n * Return a string representing the value of this BigNumber to sd significant digits and rounded\r\n * using ROUNDING_MODE if necessary. If sd is less than the number of digits necessary to\r\n * represent the integer part of the value in normal notation, then use exponential notation.\r\n *\r\n * sd {number} Integer, 1 to MAX inclusive.\r\n */\r\n P['toPrecision'] = function (sd) {\r\n var x = this;\r\n\r\n // ERRORS true: Throw if sd not undefined, null or an integer in range.\r\n // ERRORS false: Ignore sd if not a number or not in range.\r\n // Truncate non-integers.\r\n return sd == null || ( ( ( outOfRange = sd < 1 || sd > MAX ) || parse(sd) != sd ) &&\r\n\r\n // 'toPrecision() precision not an integer: {sd}'\r\n // 'toPrecision() precision out of range: {sd}'\r\n !ifExceptionsThrow( sd, 'precision', 'toPrecision' ) ) || !x['c']\r\n ? x.toString() : format( x, --sd | 0, 2 );\r\n };\r\n\r\n\r\n /*\r\n * Return a string representing the value of this BigNumber in base b, or base 10 if b is\r\n * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and\r\n * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent that is\r\n * equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than TO_EXP_NEG,\r\n * return exponential notation.\r\n *\r\n * [b] {number} Integer, 2 to 64 inclusive.\r\n */\r\n P['toString'] = function (b) {\r\n var u, str, strL,\r\n x = this,\r\n xe = x['e'];\r\n\r\n // Infinity or NaN?\r\n if ( xe === null ) {\r\n str = x['s'] ? 'Infinity' : 'NaN';\r\n\r\n // Exponential format?\r\n } else if ( b == u && ( xe <= TO_EXP_NEG || xe >= TO_EXP_POS ) ) {\r\n return format( x, u, 1 );\r\n } else {\r\n str = coefficientToString( x['c'] );\r\n\r\n // Negative exponent?\r\n if ( xe < 0 ) {\r\n\r\n // Prepend zeros.\r\n for ( ; ++xe; str = '0' + str );\r\n str = '0.' + str;\r\n\r\n // Positive exponent?\r\n } else if ( strL = str.length, xe > 0 ) {\r\n\r\n // Append zeros.\r\n if ( ++xe > strL ) {\r\n for ( xe -= strL; xe-- ; str += '0' );\r\n } else if ( xe < strL ) {\r\n str = str.slice( 0, xe ) + '.' + str.slice(xe);\r\n }\r\n\r\n // Exponent zero.\r\n } else {\r\n u = str.charAt(0);\r\n\r\n if ( strL > 1 ) {\r\n str = u + '.' + str.slice(1);\r\n\r\n // Avoid '-0'\r\n } else if ( u == '0' ) {\r\n return u;\r\n }\r\n }\r\n\r\n if ( b != null ) {\r\n\r\n if ( !( outOfRange = !( b >= 2 && b < 65 ) ) && ( b == ~~b || !ERRORS ) ) {\r\n str = convertBase( str, b | 0, 10, x['s'] );\r\n\r\n // Avoid '-0'\r\n if ( str == '0' ) return str;\r\n } else {\r\n\r\n // 'toString() base not an integer: {b}'\r\n // 'toString() base out of range: {b}'\r\n ifExceptionsThrow( b, 'base', 'toS' );\r\n }\r\n }\r\n\r\n }\r\n\r\n return x['s'] < 0 ? '-' + str : str;\r\n };\r\n\r\n\r\n /*\r\n * Return as toString, but do not accept a base argument.\r\n */\r\n P['valueOf'] = P['toJSON'] = function () {\r\n return this.toString();\r\n };\r\n\r\n\r\n // Add aliases for BigDecimal methods.\r\n //P['add'] = P['plus'];\r\n //P['subtract'] = P['minus'];\r\n //P['multiply'] = P['times'];\r\n //P['divide'] = P['div'];\r\n //P['remainder'] = P['mod'];\r\n //P['compareTo'] = P['cmp'];\r\n //P['negate'] = P['neg'];\r\n\r\n\r\n // EXPORT\r\n\r\n\r\n // Node and other CommonJS-like environments that support module.exports.\r\n if ( typeof module !== 'undefined' && module.exports ) {\r\n module.exports = BigNumber;\r\n //AMD.\r\n } else if ( typeof define == 'function' && define.amd ) {\r\n define( function () {return BigNumber} );\r\n //Browser.\r\n } else {\r\n global['BigNumber'] = BigNumber;\r\n }\r\n})(this);\r\n",
+ "// dont override global variable\nif (typeof web3 !== 'undefined') {\n var web3;\n}\n\nweb3 = require('./lib/web3');\nweb3.providers.HttpProvider = require('./lib/web3/httpprovider');\nweb3.providers.QtSyncProvider = require('./lib/web3/qtsync');\nweb3.eth.contract = require('./lib/web3/contract');\nweb3.abi = require('./lib/solidity/abi');\n\n\n\nmodule.exports = web3;\n"
+ ]
+}
\ No newline at end of file
diff --git a/libjsqrc/ethereumjs/dist/web3.min.js b/libjsqrc/ethereumjs/dist/web3.min.js
new file mode 100644
index 000000000..285b71c67
--- /dev/null
+++ b/libjsqrc/ethereumjs/dist/web3.min.js
@@ -0,0 +1,2 @@
+require=function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;av;v++)d.push(h(e.slice(0,u))),e=e.slice(u);n.push(d)}else i.prefixedType("bytes")(t[c].type)?(l=l.slice(u),n.push(h(e.slice(0,u))),e=e.slice(u)):(n.push(h(e.slice(0,u))),e=e.slice(u))}),n},h=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),i=n.extractTypeName(t.name),o=function(){var e=Array.prototype.slice.call(arguments);return l(t.inputs,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e},g=function(t){var e={};return t.forEach(function(t){var r=n.extractDisplayName(t.name),i=n.extractTypeName(t.name),o=function(e){return m(t.outputs,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e};e.exports={inputParser:h,outputParser:g,formatInput:l,formatOutput:m}},{"../utils/config":6,"../utils/utils":7,"./formatters":2,"./types":3}],2:[function(t,e){var n=t("bignumber.js"),r=t("../utils/utils"),i=t("../utils/config"),o=function(t){var e=2*i.ETH_PADDING;return n.config(i.ETH_BIGNUMBER_ROUNDING_MODE),r.padLeft(r.toTwosComplement(t).round().toString(16),e)},a=function(t){return r.fromAscii(t,i.ETH_PADDING).substr(2)},s=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},u=function(t){return o(new n(t).times(new n(2).pow(128)))},c=function(t){return"1"===new n(t.substr(0,1),16).toString(2).substr(0,1)},l=function(t){return t=t||"0",c(t)?new n(t,16).minus(new n("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new n(t,16)},f=function(t){return t=t||"0",new n(t,16)},p=function(t){return l(t).dividedBy(new n(2).pow(128))},m=function(t){return f(t).dividedBy(new n(2).pow(128))},h=function(t){return"0x"+t},g=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},d=function(t){return r.toAscii(t)},v=function(t){return"0x"+t.slice(t.length-40,t.length)};e.exports={formatInputInt:o,formatInputString:a,formatInputBool:s,formatInputReal:u,formatOutputInt:l,formatOutputUInt:f,formatOutputReal:p,formatOutputUReal:m,formatOutputHash:h,formatOutputBool:g,formatOutputString:d,formatOutputAddress:v}},{"../utils/config":6,"../utils/utils":7,"bignumber.js":"bignumber.js"}],3:[function(t,e){var n=t("./formatters"),r=function(t){return function(e){return 0===e.indexOf(t)}},i=function(t){return function(e){return t===e}},o=function(){return[{type:r("uint"),format:n.formatInputInt},{type:r("int"),format:n.formatInputInt},{type:r("bytes"),format:n.formatInputString},{type:r("real"),format:n.formatInputReal},{type:r("ureal"),format:n.formatInputReal},{type:i("address"),format:n.formatInputInt},{type:i("bool"),format:n.formatInputBool}]},a=function(){return[{type:r("uint"),format:n.formatOutputUInt},{type:r("int"),format:n.formatOutputInt},{type:r("bytes"),format:n.formatOutputString},{type:r("real"),format:n.formatOutputReal},{type:r("ureal"),format:n.formatOutputUReal},{type:i("address"),format:n.formatOutputAddress},{type:i("bool"),format:n.formatOutputBool}]};e.exports={prefixedType:r,namedType:i,inputTypes:o,outputTypes:a}},{"./formatters":2}],4:[function(t,e){"use strict";e.exports=BigNumber},{}],5:[function(t,e,n){"use strict";n.XMLHttpRequest="undefined"==typeof XMLHttpRequest?{}:XMLHttpRequest},{}],6:[function(t,e){var n=t("bignumber.js"),r=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];e.exports={ETH_PADDING:32,ETH_SIGNATURE_LENGTH:4,ETH_UNITS:r,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:n.ROUND_DOWN},ETH_POLLING_TIMEOUT:1e3,ETH_DEFAULTBLOCK:"latest"}},{"bignumber.js":"bignumber.js"}],7:[function(t,e){var n=t("bignumber.js"),r={wei:"1",kwei:"1000",ada:"1000",mwei:"1000000",babbage:"1000000",gwei:"1000000000",shannon:"1000000000",szabo:"1000000000000",finney:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",einstein:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"},i=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},o=function(t,e){for(var n=!1,r=0;rn;n+=2){var i=parseInt(t.substr(n,2),16);if(0===i)break;e+=String.fromCharCode(i)}return e},s=function(t){for(var e="",n=0;n1?(t[n[0]]=t[n[0]]||{},t[n[0]][n[1]]=e):t[n[0]]=e},o.prototype.toPayload=function(t){var e=this.getCall(t),n=this.extractCallback(t),r=this.formatInput(t);return this.validateArgs(r),{method:e,params:r,callback:n}},o.prototype.send=function(){var t=this.toPayload(Array.prototype.slice.call(arguments));if(t.callback){var e=this;return n.getInstance().sendAsync(t,function(n,r){t.callback(null,e.formatOutput(r))})}return this.formatOutput(n.getInstance().send(t))},e.exports=o},{"../utils/utils":7,"./errors":12,"./requestmanager":23}],20:[function(t,e){var n=t("../utils/utils"),r=t("./property"),i=[],o=[new r({name:"listening",getter:"net_listening"}),new r({name:"peerCount",getter:"net_peerCount",outputFormatter:n.toDecimal})];e.exports={methods:i,properties:o}},{"../utils/utils":7,"./property":21}],21:[function(t,e){var n=t("./requestmanager"),r=function(t){this.name=t.name,this.getter=t.getter,this.setter=t.setter,this.outputFormatter=t.outputFormatter,this.inputFormatter=t.inputFormatter};r.prototype.formatInput=function(t){return this.inputFormatter?this.inputFormatter(t):t},r.prototype.formatOutput=function(t){return this.outputFormatter&&null!==t?this.outputFormatter(t):t},r.prototype.attachToObject=function(t){var e={get:this.get.bind(this),set:this.set.bind(this)},n=this.name.split(".");n.length>1?(t[n[0]]=t[n[0]]||{},Object.defineProperty(t[n[0]],n[1],e)):Object.defineProperty(t,n[0],e)},r.prototype.get=function(){return this.formatOutput(n.getInstance().send({method:this.getter}))},r.prototype.set=function(t){return n.getInstance().send({method:this.setter,params:[this.formatInput(t)]})},e.exports=r},{"./requestmanager":23}],22:[function(t,e){var n=function(){};n.prototype.send=function(t){var e=navigator.qt.callMethod(JSON.stringify(t));return JSON.parse(e)},e.exports=n},{}],23:[function(t,e){var n=t("./jsonrpc"),r=t("../utils/utils"),i=t("../utils/config"),o=t("./errors"),a=function(t){return arguments.callee._singletonInstance?arguments.callee._singletonInstance:(arguments.callee._singletonInstance=this,this.provider=t,this.polls=[],this.timeout=null,void this.poll())};a.getInstance=function(){var t=new a;return t},a.prototype.send=function(t){if(!this.provider)return console.error(o.InvalidProvider),null;var e=n.getInstance().toPayload(t.method,t.params),r=this.provider.send(e);if(!n.getInstance().isValidResponse(r))throw o.InvalidResponse(r);return r.result},a.prototype.sendAsync=function(t,e){if(!this.provider)return e(o.InvalidProvider);var r=n.getInstance().toPayload(t.method,t.params);this.provider.sendAsync(r,function(t,r){return t?e(t):n.getInstance().isValidResponse(r)?void e(null,r.result):e(o.InvalidResponse(r))})},a.prototype.setProvider=function(t){this.provider=t},a.prototype.startPolling=function(t,e,n,r){this.polls.push({data:t,id:e,callback:n,uninstall:r})},a.prototype.stopPolling=function(t){for(var e=this.polls.length;e--;){var n=this.polls[e];n.id===t&&this.polls.splice(e,1)}},a.prototype.reset=function(){this.polls.forEach(function(t){t.uninstall(t.id)}),this.polls=[],this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.poll()},a.prototype.poll=function(){if(this.timeout=setTimeout(this.poll.bind(this),i.ETH_POLLING_TIMEOUT),this.polls.length){if(!this.provider)return void console.error(o.InvalidProvider);var t=n.getInstance().toBatchPayload(this.polls.map(function(t){return t.data})),e=this;this.provider.sendAsync(t,function(t,i){if(!t){if(!r.isArray(i))throw o.InvalidResponse(i);i.map(function(t,n){return t.callback=e.polls[n].callback,t}).filter(function(t){var e=n.getInstance().isValidResponse(t);return e||t.callback(o.InvalidResponse(t)),e}).filter(function(t){return r.isArray(t.result)&&t.result.length>0}).forEach(function(t){t.callback(null,t.result)})}})}},e.exports=a},{"../utils/config":6,"../utils/utils":7,"./errors":12,"./jsonrpc":18}],24:[function(t,e){var n=t("./method"),r=t("./formatters"),i=new n({name:"post",call:"shh_post",params:1,inputFormatter:r.inputPostFormatter}),o=new n({name:"newIdentity",call:"shh_newIdentity",params:0}),a=new n({name:"hasIdentity",call:"shh_hasIdentity",params:1}),s=new n({name:"newGroup",call:"shh_newGroup",params:0}),u=new n({name:"addToGroup",call:"shh_addToGroup",params:0}),c=[i,o,a,s,u];e.exports={methods:c}},{"./formatters":16,"./method":19}],25:[function(t,e){var n=t("../web3"),r=t("../utils/config"),i=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*r.ETH_SIGNATURE_LENGTH)},o=function(t){return n.sha3(n.fromAscii(t))};e.exports={functionSignatureFromAscii:i,eventSignatureFromAscii:o}},{"../utils/config":6,"../web3":9}],26:[function(t,e){var n=t("./method"),r=function(){var t=function(t){return"string"==typeof t[0]?"eth_newBlockFilter":"eth_newFilter"},e=new n({name:"newFilter",call:t,params:1}),r=new n({name:"uninstallFilter",call:"eth_uninstallFilter",params:1}),i=new n({name:"getLogs",call:"eth_getFilterLogs",params:1}),o=new n({name:"poll",call:"eth_getFilterChanges",params:1});return[e,r,i,o]},i=function(){var t=new n({name:"newFilter",call:"shh_newFilter",params:1}),e=new n({name:"uninstallFilter",call:"shh_uninstallFilter",params:1}),r=new n({name:"getLogs",call:"shh_getMessages",params:1}),i=new n({name:"poll",call:"shh_getFilterChanges",params:1});return[t,e,r,i]};e.exports={eth:r,shh:i}},{"./method":19}],"bignumber.js":[function(t,e){!function(t){"use strict";function n(t,e){var r,i,o,s,f,p,g=this;if(!(g instanceof n))return new n(t,e);if(t instanceof n){if(null==e)return I=0,g.s=t.s,g.e=t.e,void(g.c=(t=t.c)?t.slice():t);t+=""}else if(s="number"==(f=typeof t)){if(null==e&&t===~~t){for(g.s=0>1/t?(t=-t,-1):1,i=I=0,o=t;o>=10;o/=10,i++);return g.e=i,void(g.c=[t])}t=0===t&&0>1/t?"-0":t+""}else"string"!=f&&(t+="");if(f=t,null==e&&O.test(f))g.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;else{if(10==e)return g=new n(f),c(g,m+g.e+1,h);if(f=T.call(f).replace(/^\+(?!-)/,""),g.s=45===f.charCodeAt(0)?(f=f.replace(/^-(?!-)/,""),-1):1,null!=e?e!=~~e&&y||(l=!(e>=2&&65>e))?(u(e,2),p=O.test(f)):(r="["+N.slice(0,e=0|e)+"]+",f=f.replace(/\.$/,"").replace(/^\./,"0."),(p=new RegExp("^"+r+"(?:\\."+r+")?$",37>e?"i":"").test(f))?(s&&(f.replace(/^0\.0*|\./,"").length>15&&u(t,0),s=!s),f=a(f,10,e,g.s)):"Infinity"!=f&&"NaN"!=f&&(u(t,1,e),t="NaN")):p=O.test(f),!p)return g.c=g.e=null,"Infinity"!=f&&("NaN"!=f&&u(t,3),g.s=null),void(I=0)}for((i=f.indexOf("."))>-1&&(f=f.replace(".","")),(o=f.search(/e/i))>0?(0>i&&(i=o),i+=+f.slice(o+1),f=f.substring(0,o)):0>i&&(i=f.length),o=0;48===f.charCodeAt(o);o++);for(e=f.length;48===f.charCodeAt(--e););if(f=f.slice(o,e+1))if(e=f.length,s&&e>15&&u(t,0),i=i-o-1,i>b)g.c=g.e=null;else if(v>i)g.c=[g.e=0];else{if(g.e=i,g.c=[],o=(i+1)%B,0>i&&(o+=B),e>o){for(o&&g.c.push(+f.slice(0,o)),e-=B;e>o;g.c.push(+f.slice(o,o+=B)));f=f.slice(o),o=B-f.length}else o-=e;for(;o--;f+="0");g.c.push(+f)}else g.c=[g.e=0];I=0}function r(t,e,n){for(var r=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,r++);return(n=r+n*B-1)>b?t.c=t.e=null:v>n?t.c=[t.e=0]:(t.e=n,t.c=e),t}function i(t){for(var e,n,r=1,i=t.length,o=t[0]+"";i>r;){for(e=t[r++]+"",n=B-e.length;n--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function o(t,e,n){for(var r,i,o=[0],a=0,s=t.length;s>a;){for(i=o.length;i--;o[i]*=e);for(o[r=0]+=N.indexOf(t.charAt(a++));rn-1&&(null==o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/n|0,o[r]%=n)}return o.reverse()}function a(t,e,r,i){var a,s,u,c,l,f,p,g=t.indexOf("."),d=h;for(37>r&&(t=t.toLowerCase()),g>=0&&(t=t.replace(".",""),p=new n(r),l=p.pow(t.length-g),p.c=o(l.toFixed(),10,e),p.e=p.c.length),f=o(t,r,e),s=u=f.length;0==f[--u];f.pop());if(!f[0])return"0";if(0>g?--s:(l.c=f,l.e=s,l.s=i,l=k(l,p,m,d,e),f=l.c,c=l.r,s=l.e),a=s+m+1,g=f[a],u=e/2,c=c||0>a||null!=f[a+1],c=4>d?(null!=g||c)&&(0==d||d==(l.s<0?3:2)):g>u||g==u&&(4==d||c||6==d&&1&f[a-1]||d==(l.s<0?8:7)),1>a||!f[0])f.length=1,u=0,c?(f[0]=1,s=-m):s=f[0]=0;else{if(f.length=a,c)for(--e;++f[--a]>e;)f[a]=0,a||(++s,f.unshift(1));for(u=f.length;!f[--u];);}for(g=0,t="";u>=g;t+=N.charAt(f[g++]));if(0>s){for(;++s;t="0"+t);t="0."+t}else if(g=t.length,++s>g)for(s-=g;s--;t+="0");else g>s&&(t=t.slice(0,s)+"."+t.slice(s));return t}function s(t,e,r){var o,a,s,u=(t=new n(t)).e;if(null==e?o=0:(c(t,++e,h),o=r?e:e+t.e-u,u=t.e),a=i(t.c),1==r||2==r&&(u>=e||g>=u)){for(;a.length1&&(a=a.charAt(0)+"."+a.slice(1)),a+=(0>u?"e":"e+")+u}else{if(r=a.length,0>u){for(s=o-r;++u;a="0"+a);a="0."+a}else if(++u>r){for(s=o-u,u-=r;u--;a+="0");s>0&&(a+=".")}else s=o-r,r>u?a=a.slice(0,u)+"."+a.slice(u):s>0&&(a+=".");if(s>0)for(;s--;a+="0");}return t.s<0&&t.c[0]?"-"+a:a}function u(t,e,n,r,i,o){if(y){var a,s=["new BigNumber","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFraction","divToInt"][I?0>I?-I:I:0>1/I?1:0]+"()",u=l?" out of range":" not a"+(i?" non-zero":"n")+" integer";throw u=([s+" number type has more than 15 significant digits",s+" not a base "+n+" number",s+" base"+u,s+" not a number"][e]||n+"() "+e+(o?" not a boolean or binary digit":u+(r?" or not ["+(l?" negative, positive":" integer, integer")+" ]":"")))+": "+t,l=I=0,a=new Error(u),a.name="BigNumber Error",a}}function c(t,e,n,r){var i,o,a,s,u,c,l,f,p=D;if(f=t.c){t:{for(i=1,s=f[0];s>=10;s/=10,i++);if(o=e-i,0>o)o+=B,a=e,u=f[c=0],l=u/p[i-a-1]%10|0;else if(c=Math.ceil((o+1)/B),c>=f.length){if(!r)break t;for(;f.length<=c;f.push(0));u=l=0,i=1,o%=B,a=o-B+1}else{for(u=s=f[c],i=1;s>=10;s/=10,i++);o%=B,a=o-B+i,l=0>a?0:u/p[i-a-1]%10|0}if(r=r||0>e||null!=f[c+1]||(0>a?u:u%p[i-a-1]),r=4>n?(l||r)&&(0==n||n==(t.s<0?3:2)):l>5||5==l&&(4==n||r||6==n&&(o>0?a>0?u/p[i-a]:0:f[c-1])%10&1||n==(t.s<0?8:7)),1>e||!f[0])return f.length=0,r?(e-=t.e+1,f[0]=p[e%B],t.e=-e||0):f[0]=t.e=0,t;
+if(0==o?(f.length=c,s=1,c--):(f.length=c+1,s=p[B-o],f[c]=a>0?_(u/p[i-a]%p[a])*s:0),r)for(;;){if(0==c){for(o=1,a=f[0];a>=10;a/=10,o++);for(a=f[0]+=s,s=1;a>=10;a/=10,s++);o!=s&&(t.e++,f[0]==E&&(f[0]=1));break}if(f[c]+=s,f[c]!=E)break;f[c--]=0,s=1}for(o=f.length;0===f[--o];f.pop());}t.e>b?t.c=t.e=null:t.et||t>n)||w(t)!=t&&0!==t)},c=o&&"object"==typeof o?function(){return o.hasOwnProperty(e)?null!=(t=o[e]):void 0}:function(){return i.length>n?null!=(t=i[n++]):void 0};if(c(e="DECIMAL_PLACES")&&(s(t,0,f)?m=0|t:u(t,e,a)),r[e]=m,c(e="ROUNDING_MODE")&&(s(t,0,8)?h=0|t:u(t,e,a)),r[e]=h,c(e="EXPONENTIAL_AT")&&(s(t,-f,f)?g=-(d=~~(0>t?-t:+t)):!l&&t&&s(t[0],-f,0)&&s(t[1],0,f)?(g=~~t[0],d=~~t[1]):u(t,e,a,1)),r[e]=[g,d],c(e="RANGE")&&(s(t,-f,f)&&~~t?v=-(b=~~(0>t?-t:+t)):!l&&t&&s(t[0],-f,-1)&&s(t[1],1,f)?(v=~~t[0],b=~~t[1]):u(t,e,a,1,1)),r[e]=[v,b],c(e="ERRORS")&&(t===!!t||1===t||0===t?(l=I=0,w=(y=!!t)?parseInt:parseFloat):u(t,e,a,0,0,1)),r[e]=y,c(e="FORMAT"))if("object"==typeof t)x=t;else if(y)throw r=new Error(a+"() "+e+" not an object: "+t),r.name="BigNumber Error",r;return r[e]=x,r};var k=function(){function t(t,e,n){var r,i,o,a,s=0,u=t.length,c=e%A,l=e/A|0;for(t=t.slice();u--;)o=t[u]%A,a=t[u]/A|0,r=l*o+a*c,i=c*o+r%A*A+s,s=(i/n|0)+(r/A|0)+l*a,t[u]=i%n;return s&&t.unshift(s),t}function e(t,e,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;n>i;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function r(t,e,n,r){for(var i=0;n--;)t[n]-=i,i=t[n]1;t.shift());}return function(i,o,a,s,u){var l,f,p,m,h,g,d,v,b,y,w,x,F,N,I,O,T,A=i.s==o.s?1:-1,D=i.c,S=o.c;if(!(D&&D[0]&&S&&S[0]))return new n(i.s&&o.s&&(D?!S||D[0]!=S[0]:S)?D&&0==D[0]||!S?0*A:A/0:0/0);for(v=new n(A),b=v.c=[],f=i.e-o.e,A=a+f+1,u||(u=E,N=i.e/B,p=0|N,f=(N>0||N===p?p:p-1)-(O=o.e/B,p=0|O,O>0||O===p?p:p-1),A=A/B|0),p=0;S[p]==(D[p]||0);p++);if(S[p]>(D[p]||0)&&f--,0>A)b.push(1),m=!0;else{for(N=D.length,O=S.length,p=0,A+=2,h=_(u/(S[0]+1)),h>1&&(S=t(S,h,u),D=t(D,h,u),O=S.length,N=D.length),F=O,y=D.slice(0,O),w=y.length;O>w;y[w++]=0);T=S.slice(),T.unshift(0),I=S[0],S[1]>=u/2&&I++;do h=0,l=e(S,y,O,w),0>l?(x=y[0],O!=w&&(x=x*u+(y[1]||0)),h=_(x/I),h>1?(h>=u&&(h=u-1),g=t(S,h,u),d=g.length,w=y.length,l=e(g,y,d,w),1==l&&(h--,r(g,d>O?T:S,d,u))):(0==h&&(l=h=1),g=S.slice()),d=g.length,w>d&&g.unshift(0),r(y,g,w,u),-1==l&&(w=y.length,l=e(S,y,O,w),1>l&&(h++,r(y,w>O?T:S,w,u))),w=y.length):0===l&&(h++,y=[0]),b[p++]=h,l&&y[0]?y[w++]=D[F]||0:(y=[D[F]],w=1);while((F++=10;A/=10,p++);c(v,a+(v.e=p+f*B-1)+1,s,m)}else v.e=f,v.r=+m;return v}}();F.absoluteValue=F.abs=function(){var t=new n(this);return t.s<0&&(t.s=1),t},F.ceil=function(){return c(new n(this),this.e+1,2)},F.comparedTo=F.cmp=function(t,e){var r,i=this,o=i.c,a=(I=-I,t=new n(t,e)).c,s=i.s,u=t.s,c=i.e,l=t.e;if(!s||!u)return null;if(r=o&&!o[0],e=a&&!a[0],r||e)return r?e?0:-u:s;if(s!=u)return s;if(r=0>s,e=c==l,!o||!a)return e?0:!o^r?1:-1;if(!e)return c>l^r?1:-1;for(s=-1,u=(c=o.length)<(l=a.length)?c:l;++sa[s]^r?1:-1;return c==l?0:c>l^r?1:-1},F.decimalPlaces=F.dp=function(){var t,e,n=this.c;if(!n)return null;if(t=((e=n.length-1)-_(this.e/B))*B,e=n[e])for(;e%10==0;e/=10,t--);return 0>t&&(t=0),t},F.dividedBy=F.div=function(t,e){return I=2,k(this,new n(t,e),m,h)},F.dividedToIntegerBy=F.divToInt=function(t,e){return I=13,k(this,new n(t,e),0,1)},F.equals=F.eq=function(t,e){return I=3,0===this.cmp(t,e)},F.floor=function(){return c(new n(this),this.e+1,3)},F.greaterThan=F.gt=function(t,e){return I=4,this.cmp(t,e)>0},F.greaterThanOrEqualTo=F.gte=function(t,e){return I=5,1==(e=this.cmp(t,e))||0===e},F.isFinite=function(){return!!this.c},F.isInteger=F.isInt=function(){return!!this.c&&_(this.e/B)>this.c.length-2},F.isNaN=function(){return!this.s},F.isNegative=F.isNeg=function(){return this.s<0},F.isZero=function(){return!!this.c&&0==this.c[0]},F.lessThan=F.lt=function(t,e){return I=6,this.cmp(t,e)<0},F.lessThanOrEqualTo=F.lte=function(t,e){return I=7,-1==(e=this.cmp(t,e))||0===e},F.minus=function(t,e){var i,o,a,s,u=this,c=u.s;if(I=8,t=new n(t,e),e=t.s,!c||!e)return new n(0/0);if(c!=e)return t.s=-e,u.plus(t);var l=u.e/B,f=t.e/B,p=u.c,m=t.c;if(!l||!f){if(!p||!m)return p?(t.s=-e,t):new n(m?u:0/0);if(!p[0]||!m[0])return m[0]?(t.s=-e,t):new n(p[0]?u:3==h?-0:0)}if(i=0|l,l=l>0||l===i?i:i-1,i=0|f,f=f>0||f===i?i:i-1,p=p.slice(),c=l-f){for((s=0>c)?(c=-c,a=p):(f=l,a=m),a.reverse(),e=c;e--;a.push(0));a.reverse()}else for(o=(s=(c=p.length)<(e=m.length))?c:e,c=e=0;o>e;e++)if(p[e]!=m[e]){s=p[e]0)for(;e--;p[i++]=0);for(e=E-1;o>c;){if(p[--o]0||s===a?a:a-1,a=0|u,u=u>0||u===a?a:a-1,c=c.slice(),a=s-u){for(a>0?(u=s,i=l):(a=-a,i=c),i.reverse();a--;i.push(0));i.reverse()}for(a=c.length,e=l.length,0>a-e&&(i=l,l=c,c=i,e=a),a=0;e;)a=(c[--e]=c[e]+l[e]+a)/E|0,c[e]%=E;return a&&(c.unshift(a),++u),r(t,c,u)},F.round=function(t,e){return t=null==t||((l=0>t||t>f)||w(t)!=t)&&!u(t,"decimal places","round")?0:0|t,e=null==e||((l=0>e||e>8)||w(e)!=e&&0!==e)&&!u(e,"mode","round")?h:0|e,c(new n(this),t+this.e+1,e)},F.squareRoot=F.sqrt=function(){var t,e,r,o,a,s=this,u=s.c,l=s.s,f=s.e,p=m+4,g=new n("0.5");if(1!==l||!u||!u[0])return new n(!l||0>l&&(!u||u[0])?0/0:u?s:1/0);if(l=Math.sqrt(+s),0==l||l==1/0?(e=i(u),(e.length+f)%2==0&&(e+="0"),l=Math.sqrt(e),f=_((f+1)/2)-(0>f||f%2),l==1/0?e="1e"+f:(e=l.toExponential(),e=e.slice(0,e.indexOf("e")+1)+f),r=new n(e)):r=new n(l.toString()),r.c[0])for(f=r.e,l=f+p,3>l&&(l=0);;)if(a=r,r=g.times(a.plus(k(s,a,p,1))),i(a.c).slice(0,l)===(e=i(r.c)).slice(0,l)){if(r.e0||d===o?o:o-1)+(o=0|v,v>0||v===o?o:o-1),b=h.length,e=g.length,e>b&&(u=h,h=g,g=u,v=b,b=e,e=v),v=b+e,u=[];v--;u.push(0));for(d=e;--d>=0;){for(i=0,v=b+d,a=b,f=g[d]%A,p=g[d]/A|0;v>d;)c=h[--a]%A,l=h[a]/A|0,s=p*c+l*f,c=f*c+s%A*A+u[v]+i,i=(c/E|0)+(s/A|0)+p*l,u[v--]=c%E;u[v]=i}return i?++o:u.shift(),r(t,u,o)},F.toExponential=function(t){var e=this;return e.c?s(e,null==t||((l=0>t||t>f)||w(t)!=t&&0!==t)&&!u(t,"decimal places","toExponential")?null:0|t,1):e.toString()},F.toFixed=function(t){var e,n=this,r=g,i=d;return t=null==t||((l=0>t||t>f)||w(t)!=t&&0!==t)&&!u(t,"decimal places","toFixed")?null:n.e+(0|t),g=-(d=1/0),null!=t&&n.c?(e=s(n,t),n.s<0&&n.c&&(n.c[0]?e.indexOf("-")<0&&(e="-"+e):e=e.replace("-",""))):e=n.toString(),g=r,d=i,e},F.toFormat=function(t){var e=this;if(!e.c)return e.toString();var n,r=e.s<0,i=x.groupSeparator,o=+x.groupSize,a=+x.secondaryGroupSize,s=e.toFixed(t).split("."),u=s[0],c=s[1],l=r?u.slice(1):u,f=l.length;if(a&&(n=o,o=a,a=n,f-=n),o>0&&f>0){for(n=f%o||o,u=l.substr(0,n);f>n;n+=o)u+=i+l.substr(n,o);a>0&&(u+=i+l.slice(n)),r&&(u="-"+u)}return c?u+x.decimalSeparator+((a=+x.fractionGroupSize)?c.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+x.fractionGroupSeparator):c):u},F.toFraction=function(t){var e,r,o,a,s,c,f,p,m,g=r=new n(S),d=f=new n(S),v=this,w=v.c,x=new n(S);if(!w)return v.toString();for(m=i(w),a=x.e=m.length-v.e-1,x.c[0]=D[(s=a%B)<0?B+s:s],(null==t||(!(I=12,c=new n(t)).s||(l=c.cmp(g)<0||!c.c)||y&&_(c.e/B)0)&&(t=a>0?x:g),s=b,b=1/0,c=new n(m),f.c[0]=0;p=k(c,x,0,1),o=r.plus(p.times(d)),1!=o.cmp(t);)r=d,d=o,g=f.plus(p.times(o=g)),f=o,x=c.minus(p.times(o=x)),c=o;return o=k(t.minus(r),d,0,1),f=f.plus(o.times(g)),r=r.plus(o.times(d)),f.s=g.s=v.s,a*=2,e=k(g,d,a,h).minus(v).abs().cmp(k(f,r,a,h).minus(v).abs())<1?[g.toString(),d.toString()]:[f.toString(),r.toString()],b=s,e},F.toNumber=function(){var t=this;return+t||(t.s?0*t.s:0/0)},F.toPower=F.pow=function(t){var e=0*t==0?~~t:t,r=new n(this),i=new n(S);if(((l=-p>t||t>p)&&(e=1*t/0)||w(t)!=t&&0!==t&&!(e=0/0))&&!u(t,"exponent","pow")||!e)return new n(Math.pow(+r,e));for(e=0>e?-e:e;1&e&&(i=i.times(r)),e>>=1,e;)r=r.times(r);return 0>t?S.div(i):i},F.toPrecision=function(t){var e=this;return null!=t&&(!(l=1>t||t>f)&&w(t)==t||u(t,"precision","toPrecision"))&&e.c?s(e,0|--t,2):e.toString()},F.toString=function(t){var e,n,r,o=this,c=o.e;if(null===c)n=o.s?"Infinity":"NaN";else{if(t==e&&(g>=c||c>=d))return s(o,e,1);if(n=i(o.c),0>c){for(;++c;n="0"+n);n="0."+n}else if(r=n.length,c>0)if(++c>r)for(c-=r;c--;n+="0");else r>c&&(n=n.slice(0,c)+"."+n.slice(c));else if(e=n.charAt(0),r>1)n=e+"."+n.slice(1);else if("0"==e)return e;if(null!=t)if((l=!(t>=2&&65>t))||t!=~~t&&y)u(t,"base","toS");else if(n=a(n,0|t,10,o.s),"0"==n)return n}return o.s<0?"-"+n:n},F.valueOf=F.toJSON=function(){return this.toString()},"undefined"!=typeof e&&e.exports?e.exports=n:"function"==typeof define&&define.amd?define(function(){return n}):t.BigNumber=n}(this)},{}],web3:[function(t,e){if("undefined"!=typeof n)var n;n=t("./lib/web3"),n.providers.HttpProvider=t("./lib/web3/httpprovider"),n.providers.QtSyncProvider=t("./lib/web3/qtsync"),n.eth.contract=t("./lib/web3/contract"),n.abi=t("./lib/solidity/abi"),e.exports=n},{"./lib/solidity/abi":1,"./lib/web3":9,"./lib/web3/contract":10,"./lib/web3/httpprovider":17,"./lib/web3/qtsync":22}]},{},["web3"]);
\ No newline at end of file
diff --git a/libjsqrc/ethereumjs/example/balance.html b/libjsqrc/ethereumjs/example/balance.html
index 0c2c4b8ef..02240be8b 100644
--- a/libjsqrc/ethereumjs/example/balance.html
+++ b/libjsqrc/ethereumjs/example/balance.html
@@ -2,8 +2,8 @@
-
-
+
+
+
+
+
+