Browse Source

Reworked all of JSONRPC impls to be more inclusive over their exceptioning.

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

Conflicts:
	libweb3jsonrpc/WebThreeStubServerBase.cpp
cl-refactor
Gav Wood 10 years ago
parent
commit
dcea00c7ac
  1. 2
      alethzero/MainWin.cpp
  2. 18
      libdevcore/CommonJS.cpp
  3. 38
      libdevcore/CommonJS.h
  4. 69
      libethereum/Client.cpp
  5. 13
      libethereum/Client.h
  6. 11
      libethereum/Interface.h
  7. 4
      libjsqrc/ethereumjs/.travis.yml
  8. 4
      libjsqrc/ethereumjs/.versions
  9. 42
      libjsqrc/ethereumjs/README.md
  10. 9
      libjsqrc/ethereumjs/bower.json
  11. 2999
      libjsqrc/ethereumjs/dist/ethereum.js
  12. 72
      libjsqrc/ethereumjs/dist/ethereum.js.map
  13. 2
      libjsqrc/ethereumjs/dist/ethereum.min.js
  14. 15
      libjsqrc/ethereumjs/example/balance.html
  15. 12
      libjsqrc/ethereumjs/example/contract.html
  16. 12
      libjsqrc/ethereumjs/example/contract_with_array.html
  17. 2
      libjsqrc/ethereumjs/example/event.html
  18. 4
      libjsqrc/ethereumjs/example/event_inc.html
  19. 6
      libjsqrc/ethereumjs/example/natspec_contract.html
  20. 4
      libjsqrc/ethereumjs/example/node-app.js
  21. 2
      libjsqrc/ethereumjs/gulpfile.js
  22. 8
      libjsqrc/ethereumjs/index.js
  23. 96
      libjsqrc/ethereumjs/karma.conf.js
  24. 85
      libjsqrc/ethereumjs/lib/eth.js
  25. 18
      libjsqrc/ethereumjs/lib/local.js
  26. 112
      libjsqrc/ethereumjs/lib/requestmanager.js
  27. 96
      libjsqrc/ethereumjs/lib/solidity/abi.js
  28. 161
      libjsqrc/ethereumjs/lib/solidity/formatters.js
  29. 0
      libjsqrc/ethereumjs/lib/solidity/types.js
  30. 143
      libjsqrc/ethereumjs/lib/utils.js
  31. 18
      libjsqrc/ethereumjs/lib/utils/config.js
  32. 448
      libjsqrc/ethereumjs/lib/utils/utils.js
  33. 201
      libjsqrc/ethereumjs/lib/web3.js
  34. 72
      libjsqrc/ethereumjs/lib/web3/contract.js
  35. 0
      libjsqrc/ethereumjs/lib/web3/db.js
  36. 148
      libjsqrc/ethereumjs/lib/web3/eth.js
  37. 18
      libjsqrc/ethereumjs/lib/web3/event.js
  38. 104
      libjsqrc/ethereumjs/lib/web3/filter.js
  39. 203
      libjsqrc/ethereumjs/lib/web3/formatters.js
  40. 47
      libjsqrc/ethereumjs/lib/web3/httpprovider.js
  41. 0
      libjsqrc/ethereumjs/lib/web3/jsonrpc.js
  42. 41
      libjsqrc/ethereumjs/lib/web3/net.js
  43. 0
      libjsqrc/ethereumjs/lib/web3/qtsync.js
  44. 161
      libjsqrc/ethereumjs/lib/web3/requestmanager.js
  45. 11
      libjsqrc/ethereumjs/lib/web3/shh.js
  46. 4
      libjsqrc/ethereumjs/lib/web3/signature.js
  47. 8
      libjsqrc/ethereumjs/lib/web3/watches.js
  48. 7
      libjsqrc/ethereumjs/package-init.js
  49. 29
      libjsqrc/ethereumjs/package.js
  50. 39
      libjsqrc/ethereumjs/package.json
  51. 18
      libjsqrc/ethereumjs/test/abi.inputParser.js
  52. 18
      libjsqrc/ethereumjs/test/abi.outputParser.js
  53. 48
      libjsqrc/ethereumjs/test/eth.contract.js
  54. 61
      libjsqrc/ethereumjs/test/eth.methods.js
  55. 50
      libjsqrc/ethereumjs/test/event.inputParser.js
  56. 2
      libjsqrc/ethereumjs/test/event.outputParser.js
  57. 13
      libjsqrc/ethereumjs/test/filter.methods.js
  58. 28
      libjsqrc/ethereumjs/test/formatters.inputPostFormatter.js
  59. 26
      libjsqrc/ethereumjs/test/formatters.inputTransactionFormatter.js
  60. 48
      libjsqrc/ethereumjs/test/formatters.outputBlockFormatter.js
  61. 27
      libjsqrc/ethereumjs/test/formatters.outputLogFormatter.js
  62. 26
      libjsqrc/ethereumjs/test/formatters.outputPostFormatter.js
  63. 26
      libjsqrc/ethereumjs/test/formatters.outputTransactionFormatter.js
  64. 2
      libjsqrc/ethereumjs/test/jsonrpc.isValidResponse.js
  65. 2
      libjsqrc/ethereumjs/test/jsonrpc.toBatchPayload.js
  66. 2
      libjsqrc/ethereumjs/test/jsonrpc.toPayload.js
  67. 10
      libjsqrc/ethereumjs/test/net.methods.js
  68. 3
      libjsqrc/ethereumjs/test/shh.methods.js
  69. 2
      libjsqrc/ethereumjs/test/utils.extractDisplayName.js
  70. 2
      libjsqrc/ethereumjs/test/utils.extractTypeName.js
  71. 2
      libjsqrc/ethereumjs/test/utils.filters.js
  72. 43
      libjsqrc/ethereumjs/test/utils.fromDecimal.js
  73. 22
      libjsqrc/ethereumjs/test/utils.fromWei.js
  74. 23
      libjsqrc/ethereumjs/test/utils.isAddress.js
  75. 26
      libjsqrc/ethereumjs/test/utils.isBigNumber.js
  76. 21
      libjsqrc/ethereumjs/test/utils.isFunction.js
  77. 22
      libjsqrc/ethereumjs/test/utils.isString.js
  78. 45
      libjsqrc/ethereumjs/test/utils.toBigNumber.js
  79. 14
      libjsqrc/ethereumjs/test/utils.toDecimal.js
  80. 42
      libjsqrc/ethereumjs/test/utils.toHex.js
  81. 25
      libjsqrc/ethereumjs/test/utils.toWei.js
  82. 5
      libjsqrc/ethereumjs/test/web3.methods.js
  83. 2
      libjsqrc/setup.js
  84. 1002
      libweb3jsonrpc/WebThreeStubServerBase.cpp
  85. 104
      libweb3jsonrpc/WebThreeStubServerBase.h
  86. 337
      libweb3jsonrpc/abstractwebthreestubserver.h
  87. 93
      libweb3jsonrpc/spec.json
  88. 30
      mix/MixClient.cpp
  89. 7
      mix/MixClient.h
  90. 12
      mix/Web3Server.cpp
  91. 6
      mix/Web3Server.h
  92. 80
      test/TestHelper.cpp
  93. 27
      test/TestHelper.h
  94. 60
      test/state.cpp
  95. 17
      test/transaction.cpp
  96. 69
      test/vm.cpp
  97. 283
      test/webthreestubclient.h
  98. 2
      third/MainWin.cpp

2
alethzero/MainWin.cpp

@ -1171,7 +1171,7 @@ void Main::timerEvent(QTimerEvent*)
for (auto const& i: m_handlers)
{
auto ls = ethereum()->checkWatch(i.first);
auto ls = ethereum()->checkWatchSafe(i.first);
if (ls.size())
{
cnote << "FIRING WATCH" << i.first << ls.size();

18
libdevcore/CommonJS.cpp

@ -23,15 +23,17 @@
#include "CommonJS.h"
using namespace std;
namespace dev
{
bytes jsToBytes(std::string const& _s)
bytes jsToBytes(string const& _s)
{
if (_s.substr(0, 2) == "0x")
// Hex
return fromHex(_s.substr(2));
else if (_s.find_first_not_of("0123456789") == std::string::npos)
else if (_s.find_first_not_of("0123456789") == string::npos)
// Decimal
return toCompactBigEndian(bigint(_s));
else
@ -42,7 +44,7 @@ bytes padded(bytes _b, unsigned _l)
{
while (_b.size() < _l)
_b.insert(_b.begin(), 0);
return asBytes(asString(_b).substr(_b.size() - std::max(_l, _l)));
return asBytes(asString(_b).substr(_b.size() - max(_l, _l)));
}
bytes paddedRight(bytes _b, unsigned _l)
@ -54,7 +56,7 @@ bytes paddedRight(bytes _b, unsigned _l)
bytes unpadded(bytes _b)
{
auto p = asString(_b).find_last_not_of((char)0);
_b.resize(p == std::string::npos ? 0 : (p + 1));
_b.resize(p == string::npos ? 0 : (p + 1));
return _b;
}
@ -72,18 +74,18 @@ bytes unpadLeft(bytes _b)
return _b;
}
std::string fromRaw(h256 _n, unsigned* _inc)
string fromRaw(h256 _n, unsigned* _inc)
{
if (_n)
{
std::string s((char const*)_n.data(), 32);
string s((char const*)_n.data(), 32);
auto l = s.find_first_of('\0');
if (!l)
return "";
if (l != std::string::npos)
if (l != string::npos)
{
auto p = s.find_first_not_of('\0', l);
if (!(p == std::string::npos || (_inc && p == 31)))
if (!(p == string::npos || (_inc && p == 31)))
return "";
if (_inc)
*_inc = (byte)s[31];

38
libdevcore/CommonJS.h

@ -38,12 +38,21 @@ template <unsigned S> std::string toJS(FixedHash<S> const& _h)
template <unsigned N> std::string toJS(boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N, N, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> const& _n)
{
return "0x" + toHex(toCompactBigEndian(_n));
return "0x" + toHex(toCompactBigEndian(_n, 1));
}
inline std::string toJS(dev::bytes const& _n)
inline std::string toJS(bytes const& _n, std::size_t _padding = 0)
{
return "0x" + dev::toHex(_n);
bytes n = _n;
n.resize(std::max<unsigned>(n.size(), _padding));
return "0x" + toHex(n);
}
template< typename T >std::string toJS( T const& i )
{
std::stringstream stream;
stream << "0x" << std::hex << i;
return stream.str();
}
/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex.
@ -74,7 +83,7 @@ template <unsigned N> FixedHash<N> jsToFixed(std::string const& _s)
inline std::string jsToFixed(double _s)
{
return toJS(dev::u256(_s * (double)(dev::u256(1) << 128)));
return toJS(u256(_s * (double)(u256(1) << 128)));
}
template <unsigned N> boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N * 8, N * 8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>> jsToInt(std::string const& _s)
@ -92,25 +101,16 @@ template <unsigned N> boost::multiprecision::number<boost::multiprecision::cpp_i
inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); }
inline std::string jsToDecimal(std::string const& _s)
inline int jsToInt(std::string const& _s)
{
return dev::toString(jsToU256(_s));
if (_s.size() > 2 && _s.substr(0, 2).compare("0x") == 0)
return std::stoi(_s, nullptr, 16);
return std::stoi(_s, nullptr, 10);
}
inline std::string jsFromBinary(dev::bytes _s, unsigned _padding = 32)
{
_s.resize(std::max<unsigned>(_s.size(), _padding));
return "0x" + dev::toHex(_s);
}
inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32)
{
return jsFromBinary(asBytes(_s), _padding);
}
inline double jsFromFixed(std::string const& _s)
inline std::string jsToDecimal(std::string const& _s)
{
return (double)jsToU256(_s) / (double)(dev::u256(1) << 128);
return toString(jsToU256(_s));
}
}

69
libethereum/Client.cpp

@ -282,7 +282,7 @@ unsigned Client::installWatch(LogFilter const& _f)
return installWatch(h);
}
void Client::uninstallWatch(unsigned _i)
bool Client::uninstallWatch(unsigned _i)
{
cwatch << "XXX" << _i;
@ -290,7 +290,7 @@ void Client::uninstallWatch(unsigned _i)
auto it = m_watches.find(_i);
if (it == m_watches.end())
return;
return false;
auto id = it->second.id;
m_watches.erase(it);
@ -301,6 +301,7 @@ void Client::uninstallWatch(unsigned _i)
cwatch << "*X*" << fit->first << ":" << fit->second.filter;
m_filters.erase(fit);
}
return true;
}
void Client::noteChanged(h256Set const& _filters)
@ -327,19 +328,15 @@ LocalisedLogEntries Client::peekWatch(unsigned _watchId) const
{
Guard l(m_filterLock);
try {
#if ETH_DEBUG
cdebug << "peekWatch" << _watchId;
if ETH_DEBUG
cdebug << "peekWatch" << _watchId;
#endif
auto& w = m_watches.at(_watchId);
auto& w = m_watches.at(_watchId);
#if ETH_DEBUG
cdebug << "lastPoll updated to " << chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
cdebug << "lastPoll updated to " << chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
#endif
w.lastPoll = chrono::system_clock::now();
return w.changes;
} catch (...) {}
return LocalisedLogEntries();
w.lastPoll = chrono::system_clock::now();
return w.changes;
}
LocalisedLogEntries Client::checkWatch(unsigned _watchId)
@ -347,17 +344,15 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId)
Guard l(m_filterLock);
LocalisedLogEntries ret;
try {
#if ETH_DEBUG && 0
cdebug << "checkWatch" << _watchId;
cdebug << "checkWatch" << _watchId;
#endif
auto& w = m_watches.at(_watchId);
auto& w = m_watches.at(_watchId);
#if ETH_DEBUG && 0
cdebug << "lastPoll updated to " << chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
cdebug << "lastPoll updated to " << chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
#endif
std::swap(ret, w.changes);
w.lastPoll = chrono::system_clock::now();
} catch (...) {}
std::swap(ret, w.changes);
w.lastPoll = chrono::system_clock::now();
return ret;
}
@ -493,7 +488,7 @@ void Client::transact(Secret _secret, u256 _value, Address _dest, bytes const& _
m_tq.attemptImport(t.rlp());
}
bytes Client::call(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice)
bytes Client::call(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, int _blockNumber)
{
bytes out;
try
@ -503,7 +498,7 @@ bytes Client::call(Secret _secret, u256 _value, Address _dest, bytes const& _dat
// cdebug << "Nonce at " << toAddress(_secret) << " pre:" << m_preMine.transactionsFrom(toAddress(_secret)) << " post:" << m_postMine.transactionsFrom(toAddress(_secret));
{
ReadGuard l(x_stateDB);
temp = m_postMine;
temp = asOf(_blockNumber);
n = temp.transactionsFrom(toAddress(_secret));
}
Transaction t(_value, _gasPrice, _gas, _dest, _data, n, _secret);
@ -794,6 +789,11 @@ bytes Client::codeAt(Address _a, int _block) const
return asOf(_block).code(_a);
}
Transaction Client::transaction(h256 _transactionHash) const
{
return Transaction(m_bc.transaction(_transactionHash), CheckSignature::Range);
}
Transaction Client::transaction(h256 _blockHash, unsigned _i) const
{
auto bl = m_bc.block(_blockHash);
@ -828,6 +828,33 @@ unsigned Client::uncleCount(h256 _blockHash) const
return b[2].itemCount();
}
Transactions Client::transactions(h256 _blockHash) const
{
auto bl = m_bc.block(_blockHash);
RLP b(bl);
Transactions res;
for (unsigned i = 0; i < b[1].itemCount(); i++)
res.emplace_back(b[1][i].data(), CheckSignature::Range);
return res;
}
TransactionHashes Client::transactionHashes(h256 _blockHash) const
{
return m_bc.transactionHashes(_blockHash);
}
LocalisedLogEntries Client::logs(unsigned _watchId) const
{
LogFilter f;
try {
Guard l(m_filterLock);
f = m_filters.at(m_watches.at(_watchId).id).filter;
} catch (...) {
return LocalisedLogEntries();
}
return logs(f);
}
LocalisedLogEntries Client::logs(LogFilter const& _f) const
{
LocalisedLogEntries ret;

13
libethereum/Client.h

@ -225,7 +225,7 @@ public:
virtual void flushTransactions();
/// Makes the given call. Nothing is recorded into the state.
virtual bytes call(Secret _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo);
virtual bytes call(Secret _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo, int _blockNumber = 0);
/// Makes the given call. Nothing is recorded into the state. This cheats by creating a null address and endowing it with a lot of ETH.
virtual bytes call(Address _dest, bytes const& _data = bytes(), u256 _gas = 125000, u256 _value = 0, u256 _gasPrice = 1 * ether);
@ -246,13 +246,13 @@ public:
virtual bytes codeAt(Address _a, int _block) const;
virtual std::map<u256, u256> storageAt(Address _a, int _block) const;
virtual unsigned installWatch(LogFilter const& _filter);
virtual unsigned installWatch(h256 _filterId);
virtual void uninstallWatch(unsigned _watchId);
virtual unsigned installWatch(LogFilter const& _filter) override;
virtual unsigned installWatch(h256 _filterId) override;
virtual bool uninstallWatch(unsigned _watchId) override;
virtual LocalisedLogEntries peekWatch(unsigned _watchId) const;
virtual LocalisedLogEntries checkWatch(unsigned _watchId);
virtual LocalisedLogEntries logs(unsigned _watchId) const { try { Guard l(m_filterLock); return logs(m_filters.at(m_watches.at(_watchId).id).filter); } catch (...) { return LocalisedLogEntries(); } }
virtual LocalisedLogEntries logs(unsigned _watchId) const;
virtual LocalisedLogEntries logs(LogFilter const& _filter) const;
// [EXTRA API]:
@ -267,10 +267,13 @@ public:
virtual h256 hashFromNumber(unsigned _number) const { return m_bc.numberHash(_number); }
virtual BlockInfo blockInfo(h256 _hash) const { return BlockInfo(m_bc.block(_hash)); }
virtual BlockDetails blockDetails(h256 _hash) const { return m_bc.details(_hash); }
virtual Transaction transaction(h256 _transactionHash) const;
virtual Transaction transaction(h256 _blockHash, unsigned _i) const;
virtual BlockInfo uncle(h256 _blockHash, unsigned _i) const;
virtual unsigned transactionCount(h256 _blockHash) const;
virtual unsigned uncleCount(h256 _blockHash) const;
virtual Transactions transactions(h256 _blockHash) const;
virtual TransactionHashes transactionHashes(h256 _blockHash) const;
/// Differences between transactions.
using Interface::diff;

11
libethereum/Interface.h

@ -37,6 +37,8 @@ namespace dev
namespace eth
{
using TransactionHashes = h256s;
/**
* @brief Main API hub for interfacing with Ethereum.
*/
@ -65,7 +67,7 @@ public:
virtual void flushTransactions() = 0;
/// Makes the given call. Nothing is recorded into the state.
virtual bytes call(Secret _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo) = 0;
virtual bytes call(Secret _secret, u256 _value, Address _dest, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * szabo, int _blockNumber = 0) = 0;
// [STATE-QUERY API]
@ -92,7 +94,9 @@ public:
/// Install, uninstall and query watches.
virtual unsigned installWatch(LogFilter const& _filter) = 0;
virtual unsigned installWatch(h256 _filterId) = 0;
virtual void uninstallWatch(unsigned _watchId) = 0;
virtual bool uninstallWatch(unsigned _watchId) = 0;
LocalisedLogEntries peekWatchSafe(unsigned _watchId) const { try { return peekWatch(_watchId); } catch (...) { return LocalisedLogEntries; } }
LocalisedLogEntries checkWatchSafe(unsigned _watchId) { try { return checkWatch(_watchId); } catch (...) { return LocalisedLogEntries; } }
virtual LocalisedLogEntries peekWatch(unsigned _watchId) const = 0;
virtual LocalisedLogEntries checkWatch(unsigned _watchId) = 0;
@ -101,10 +105,13 @@ public:
virtual h256 hashFromNumber(unsigned _number) const = 0;
virtual BlockInfo blockInfo(h256 _hash) const = 0;
virtual BlockDetails blockDetails(h256 _hash) const = 0;
virtual Transaction transaction(h256 _transactionHash) const = 0;
virtual Transaction transaction(h256 _blockHash, unsigned _i) const = 0;
virtual BlockInfo uncle(h256 _blockHash, unsigned _i) const = 0;
virtual unsigned transactionCount(h256 _blockHash) const = 0;
virtual unsigned uncleCount(h256 _blockHash) const = 0;
virtual Transactions transactions(h256 _blockHash) const = 0;
virtual TransactionHashes transactionHashes(h256 _blockHash) const = 0;
// [EXTRA API]:

4
libjsqrc/ethereumjs/.travis.yml

@ -1,13 +1,17 @@
language: node_js
node_js:
- "0.12"
- "0.11"
- "0.10"
before_script:
- npm install
- npm install jshint
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- "jshint *.js lib"
after_script:
- npm run-script build
- npm run-script karma
- npm run-script test-coveralls

4
libjsqrc/ethereumjs/.versions

@ -0,0 +1,4 @@
3stack:bignumber@2.0.0
ethereum:js@0.0.15-rc12
meteor@1.1.4
underscore@1.0.2

42
libjsqrc/ethereumjs/README.md

@ -1,57 +1,64 @@
# Ethereum JavaScript API
This is the Ethereum compatible [JavaScript API](https://github.com/ethereum/wiki/wiki/JavaScript-API)
which implements the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) spec. It's available on npm as a node module and also for bower and component as an embeddable js
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]
<!-- [![browser support](https://ci.testling.com/ethereum/ethereum.js.png)](https://ci.testling.com/ethereum/ethereum.js) -->
You need to run a local ethrereum node to use this library.
[Documentation](https://github.com/ethereum/wiki/wiki/JavaScript-API)
## Installation
### Node.js
npm install ethereum.js
$ npm install ethereum.js
### Meteor.js
### For browser
$ meteor add ethereum:js
### As Browser module
Bower
bower install ethereum.js
$ bower install ethereum.js
Component
component install ethereum/ethereum.js
$ component install ethereum/ethereum.js
* Include `ethereum.min.js` in your html file.
* Include [bignumber.js](https://github.com/MikeMcl/bignumber.js/)
* Include `ethereum.min.js` in your html file. (not required for the meteor package)
* Include [bignumber.js](https://github.com/MikeMcl/bignumber.js/) (not required for the meteor package)
## Usage
Require the library:
Require the library (not required for the meteor package):
var web3 = require('web3');
Set a provider (QtSyncProvider, HttpSyncProvider)
Set a provider (QtSyncProvider, HttpProvider)
web3.setProvider(new web3.providers.HttpSyncProvider());
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
There you go, now you can use it:
```
var coinbase = web3.eth.coinbase;
var balance = web3.eth.balanceAt(coinbase);
var balance = web3.eth.getBalance(coinbase);
```
For another example see `example/index.html`.
## Contribute!
### Requirements
* Node.js
* npm
* gulp (build)
* mocha (tests)
```bash
sudo apt-get update
@ -73,6 +80,15 @@ npm run-script build
npm test
```
### Testing (karma)
Karma allows testing within one or several browsers.
```bash
npm run-script karma # default browsers are Chrome and Firefox
npm run-script karma -- --browsers="Chrome,Safari" # custom browsers
```
**Please note this repo is in it's early stage.**
If you'd like to run a Http ethereum node check out

9
libjsqrc/ethereumjs/bower.json

@ -1,7 +1,7 @@
{
"name": "ethereum.js",
"namespace": "ethereum",
"version": "0.0.16",
"version": "0.1.1",
"description": "Ethereum Compatible JavaScript API",
"main": [
"./dist/ethereum.js",
@ -33,6 +33,11 @@
"name": "Marian Oancea",
"email": "marian@ethdev.com",
"homepage": "https://github.com/cubedro"
},
{
"name": "Fabian Vogelsteller",
"email": "fabian@ethdev.com",
"homepage": "https://github.com/frozeman"
}
],
"license": "LGPL-3.0",
@ -41,6 +46,8 @@
"lib",
"node_modules",
"package.json",
"package.js",
".versions",
".bowerrc",
".editorconfig",
".gitignore",

2999
libjsqrc/ethereumjs/dist/ethereum.js

File diff suppressed because it is too large

72
libjsqrc/ethereumjs/dist/ethereum.js.map

File diff suppressed because one or more lines are too long

2
libjsqrc/ethereumjs/dist/ethereum.min.js

File diff suppressed because one or more lines are too long

15
libjsqrc/ethereumjs/example/balance.html

@ -7,19 +7,17 @@
<script type="text/javascript">
var web3 = require('web3');
web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
web3.setProvider(new web3.providers.HttpProvider());
function watchBalance() {
var coinbase = web3.eth.coinbase;
var originalBalance = 0;
var balance = web3.eth.balanceAt(coinbase);
var originalBalance = web3.toDecimal(balance);
document.getElementById('original').innerText = 'original balance: ' + originalBalance + ' watching...';
var originalBalance = web3.eth.getBalance(coinbase).toNumber();
document.getElementById('coinbase').innerText = 'coinbase: ' + coinbase;
document.getElementById('original').innerText = ' original balance: ' + originalBalance + ' watching...';
web3.eth.watch('pending').changed(function() {
balance = web3.eth.balanceAt(coinbase)
var currentBalance = web3.toDecimal(balance);
web3.eth.filter('pending').watch(function() {
var currentBalance = web3.eth.getBalance(coinbase).toNumber();
document.getElementById("current").innerText = 'current: ' + currentBalance;
document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance);
});
@ -31,6 +29,7 @@
<h1>coinbase balance</h1>
<button type="button" onClick="watchBalance();">watch balance</button>
<div></div>
<div id="coinbase"></div>
<div id="original"></div>
<div id="current"></div>
<div id="diff"></div>

12
libjsqrc/ethereumjs/example/contract.html

@ -7,7 +7,7 @@
<script type="text/javascript">
var web3 = require('web3');
web3.setProvider(new web3.providers.HttpSyncProvider());
web3.setProvider(new web3.providers.HttpProvider());
// solidity source code
var source = "" +
@ -35,7 +35,7 @@
]
}];
var contract;
var myContract;
function createExampleContract() {
// hide create button
@ -43,8 +43,10 @@
document.getElementById('source').innerText = source;
// create contract
var address = web3.eth.transact({code: web3.eth.solidity(source)});
contract = web3.eth.contract(address, desc);
var address = web3.eth.sendTransaction({data: web3.eth.compile.solidity(source)}),
Contract = web3.eth.contract(desc);
myContract = new Contract(address);
document.getElementById('call').style.visibility = 'visible';
}
@ -53,7 +55,7 @@
var param = parseInt(document.getElementById('value').value);
// call the contract
var res = contract.call().multiply(param);
var res = myContract.call().multiply(param);
document.getElementById('result').innerText = res.toString(10);
}

12
libjsqrc/ethereumjs/example/contract_with_array.html

@ -7,7 +7,7 @@
<script type="text/javascript">
var web3 = require('web3');
web3.setProvider(new web3.providers.HttpSyncProvider());
web3.setProvider(new web3.providers.HttpProvider());
// solidity source code
var source = "" +
@ -35,7 +35,7 @@
]
}];
var contract;
var myContract;
function createExampleContract() {
// hide create button
@ -43,8 +43,10 @@
document.getElementById('source').innerText = source;
// create contract
var address = web3.eth.transact({code: web3.eth.solidity(source)});
contract = web3.eth.contract(address, desc);
var address = web3.eth.sendTransaction({data: web3.eth.compile.solidity(source)}),
Contract = web3.eth.contract(desc);
myContract = new Contract(address);
document.getElementById('call').style.visibility = 'visible';
}
@ -54,7 +56,7 @@
var param2 = parseInt(document.getElementById('value2').value);
// call the contract
var res = contract.call().multiply([param, param2]);
var res = myContract.call().multiply([param, param2]);
document.getElementById('result').innerText = res.toString(10);
}

2
libjsqrc/ethereumjs/example/event.html

@ -5,7 +5,7 @@
<script type="text/javascript" src="../dist/ethereum.js"></script>
<script type="text/javascript">
var web3 = require('web3');
web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8080'));
var desc = [{
"type":"event",

4
libjsqrc/ethereumjs/example/event_inc.html

@ -5,7 +5,7 @@
<script type="text/javascript" src="../dist/ethereum.js"></script>
<script type="text/javascript">
var web3 = require('web3');
web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8080'));
var source = "" +
"contract Contract { " +
@ -39,7 +39,7 @@
};
var createContract = function () {
address = web3.eth.transact({code: web3.eth.solidity(source)});
address = web3.eth.sendTransaction({data: web3.eth.compile.solidity(source)});
contract = web3.eth.contract(address, desc);
contract.Incremented({odd: true}).changed(update);

6
libjsqrc/ethereumjs/example/natspec_contract.html

@ -7,7 +7,7 @@
<script type="text/javascript">
var web3 = require('web3');
web3.setProvider(new web3.providers.QtSyncProvider());
web3.setProvider(new web3.providers.HttpProvider());
// solidity source code
var source = "" +
@ -44,7 +44,7 @@
document.getElementById('source').innerText = source;
// create contract
var address = web3.eth.transact({code: web3.eth.solidity(source)});
var address = web3.eth.sendTransaction({code: web3.eth.solidity(source)});
contract = web3.eth.contract(address, desc);
document.getElementById('call').style.visibility = 'visible';
}
@ -55,7 +55,7 @@
// transaction does not return any result, cause it's not synchronous and we don't know,
// when it will be processed
contract.transact().multiply(param);
contract.sendTransaction().multiply(param);
document.getElementById('result').innerText = 'transaction made';
}

4
libjsqrc/ethereumjs/example/node-app.js

@ -2,11 +2,11 @@
var web3 = require("../index.js");
web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8080'));
var coinbase = web3.eth.coinbase;
console.log(coinbase);
var balance = web3.eth.balanceAt(coinbase);
var balance = web3.eth.getBalance(coinbase);
console.log(balance);

2
libjsqrc/ethereumjs/gulpfile.js

@ -47,8 +47,6 @@ gulp.task('build', ['clean'], function () {
return browserify(browserifyOptions)
.require('./' + src + '.js', {expose: 'web3'})
.add('./' + src + '.js')
.transform('envify', { NODE_ENV: 'build' })
.transform('unreachable-branch-transform')
.bundle()
.pipe(exorcist(path.join( DEST, dst + '.js.map')))
.pipe(source(dst + '.js'))

8
libjsqrc/ethereumjs/index.js

@ -1,7 +1,7 @@
var web3 = require('./lib/web3');
web3.providers.HttpSyncProvider = require('./lib/httpsync');
web3.providers.QtSyncProvider = require('./lib/qtsync');
web3.eth.contract = require('./lib/contract');
web3.abi = require('./lib/abi');
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;

96
libjsqrc/ethereumjs/karma.conf.js

@ -0,0 +1,96 @@
// Karma configuration
// Generated on Thu Feb 19 2015 19:57:47 GMT+0100 (W. Europe Standard Time)
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true, logLevel: config.LOG_INFO,
//singleRun: true, logLevel: config.LOG_DEBUG,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['browserify', 'mocha'],
// list of files / patterns to load in the browser
files: [
'node_modules/bignumber.js/bignumber.js',
'test/*.js',
],
// list of files to exclude
exclude: [
],
client: {
mocha: {
//ui: 'tdd'
timeout: 5000 // especially for the post requests
}
},
browserify: {
bundleDelay: 750,
debug: true
// transform: [],
// //extensions: ['.js']
},
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/*.js': ['browserify']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
// // Chrome
// // PhantomJS
browsers: ['Chrome', 'Safari', 'Firefox'],
browserNoActivityTimeout: 10000,
browserDisconnectTimeout: 5000,
customLaunchers: {
chromeWithoutSecurity: {
base: 'Chrome',
flags: ['--disable-web-security']
},
IE9: {
base: 'IE',
'x-ua-compatible': 'IE=EmulateIE9'
},
IE8: {
base: 'IE',
'x-ua-compatible': 'IE=EmulateIE8'
}
}
});
};

85
libjsqrc/ethereumjs/lib/eth.js

@ -1,85 +0,0 @@
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file eth.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
/// @returns an array of objects describing web3.eth api methods
var methods = function () {
var blockCall = function (args) {
return typeof args[0] === "string" ? "eth_blockByHash" : "eth_blockByNumber";
};
var transactionCall = function (args) {
return typeof args[0] === "string" ? 'eth_transactionByHash' : 'eth_transactionByNumber';
};
var uncleCall = function (args) {
return typeof args[0] === "string" ? 'eth_uncleByHash' : 'eth_uncleByNumber';
};
var transactionCountCall = function (args) {
return typeof args[0] === "string" ? 'eth_transactionCountByHash' : 'eth_transactionCountByNumber';
};
var uncleCountCall = function (args) {
return typeof args[0] === "string" ? 'eth_uncleCountByHash' : 'eth_uncleCountByNumber';
};
return [
{ name: 'balanceAt', call: 'eth_balanceAt' },
{ name: 'stateAt', call: 'eth_stateAt' },
{ name: 'storageAt', call: 'eth_storageAt' },
{ name: 'countAt', call: 'eth_countAt'},
{ name: 'codeAt', call: 'eth_codeAt' },
{ name: 'transact', call: 'eth_transact' },
{ name: 'call', call: 'eth_call' },
{ name: 'block', call: blockCall },
{ name: 'transaction', call: transactionCall },
{ name: 'uncle', call: uncleCall },
{ name: 'compilers', call: 'eth_compilers' },
{ name: 'flush', call: 'eth_flush' },
{ name: 'lll', call: 'eth_lll' },
{ name: 'solidity', call: 'eth_solidity' },
{ name: 'serpent', call: 'eth_serpent' },
{ name: 'logs', call: 'eth_logs' },
{ name: 'transactionCount', call: transactionCountCall },
{ name: 'uncleCount', call: uncleCountCall }
];
};
/// @returns an array of objects describing web3.eth api properties
var properties = function () {
return [
{ name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' },
{ name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' },
{ name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' },
{ name: 'gasPrice', getter: 'eth_gasPrice' },
{ name: 'accounts', getter: 'eth_accounts' },
{ name: 'peerCount', getter: 'eth_peerCount' },
{ name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' },
{ name: 'number', getter: 'eth_number'}
];
};
module.exports = {
methods: methods,
properties: properties
};

18
libjsqrc/ethereumjs/lib/local.js

@ -1,18 +0,0 @@
var addressName = {"0x12378912345789": "Gav", "0x57835893478594739854": "Jeff"};
var nameAddress = {};
for (var prop in addressName) {
if (addressName.hasOwnProperty(prop)) {
nameAddress[addressName[prop]] = prop;
}
}
var local = {
addressBook:{
byName: addressName,
byAddress: nameAddress
}
};
if (typeof(module) !== "undefined")
module.exports = local;

112
libjsqrc/ethereumjs/lib/requestmanager.js

@ -1,112 +0,0 @@
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file requestmanager.js
* @authors:
* Jeffrey Wilcke <jeff@ethdev.com>
* Marek Kotewicz <marek@ethdev.com>
* Marian Oancea <marian@ethdev.com>
* Gav Wood <g@ethdev.com>
* @date 2014
*/
var jsonrpc = require('./jsonrpc');
var c = require('./const');
/**
* 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
*/
var requestManager = function() {
var polls = [];
var timeout = null;
var provider;
var send = function (data) {
var payload = jsonrpc.toPayload(data.method, data.params);
if (!provider) {
console.error('provider is not set');
return null;
}
var result = provider.send(payload);
if (!jsonrpc.isValidResponse(result)) {
console.log(result);
return null;
}
return result.result;
};
var setProvider = function (p) {
provider = p;
};
/*jshint maxparams:4 */
var startPolling = function (data, pollId, callback, uninstall) {
polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
};
/*jshint maxparams:3 */
var stopPolling = function (pollId) {
for (var i = polls.length; i--;) {
var poll = polls[i];
if (poll.id === pollId) {
polls.splice(i, 1);
}
}
};
var reset = function () {
polls.forEach(function (poll) {
poll.uninstall(poll.id);
});
polls = [];
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
poll();
};
var poll = function () {
polls.forEach(function (data) {
var result = send(data.data);
if (!(result instanceof Array) || result.length === 0) {
return;
}
data.callback(result);
});
timeout = setTimeout(poll, c.ETH_POLLING_TIMEOUT);
};
poll();
return {
send: send,
setProvider: setProvider,
startPolling: startPolling,
stopPolling: stopPolling,
reset: reset
};
};
module.exports = requestManager;

96
libjsqrc/ethereumjs/lib/abi.js → libjsqrc/ethereumjs/lib/solidity/abi.js

@ -21,34 +21,57 @@
* @date 2014
*/
var utils = require('./utils');
var utils = require('../utils/utils');
var c = require('../utils/config');
var types = require('./types');
var c = require('./const');
var f = require('./formatters');
var displayTypeError = function (type) {
console.error('parser does not support type: ' + type);
/**
* 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
/// @returns true if it is, otherwise false
var arrayType = function (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 (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
if (isArrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
return f.formatInputInt(value.length);
return "";
};
var inputTypes = types.inputTypes();
/// Formats input params to bytes
/// @param abi contract method inputs
/// @param array of params that will be formatted to bytes
/// @returns bytes representation of input params
/**
* 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 = "";
@ -66,12 +89,12 @@ var formatInput = function (inputs, params) {
typeMatch = inputTypes[j].type(inputs[i].type, params[i]);
}
if (!typeMatch) {
displayTypeError(inputs[i].type);
throwTypeError(inputs[i].type);
}
var formatter = inputTypes[j - 1].format;
if (arrayType(inputs[i].type))
if (isArrayType(inputs[i].type))
toAppendArrayContent += params[i].reduce(function (acc, curr) {
return acc + formatter(curr);
}, "");
@ -86,18 +109,29 @@ var formatInput = function (inputs, params) {
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 (arrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
if (isArrayType(type) || type === 'string') // only string itself that is dynamic; stringX is static length.
return c.ETH_PADDING * 2;
return 0;
};
var outputTypes = types.outputTypes();
/// Formats output bytes back to param list
/// @param contract abi method outputs
/// @param bytes representtion of output
/// @returns array of output params
/**
* 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);
@ -119,11 +153,11 @@ var formatOutput = function (outs, output) {
}
if (!typeMatch) {
displayTypeError(outs[i].type);
throwTypeError(outs[i].type);
}
var formatter = outputTypes[j - 1].format;
if (arrayType(outs[i].type)) {
if (isArrayType(outs[i].type)) {
var size = f.formatOutputUInt(dynamicPart.slice(0, padding));
dynamicPart = dynamicPart.slice(padding);
var array = [];
@ -146,9 +180,14 @@ var formatOutput = function (outs, output) {
return result;
};
/// @param json abi for contract
/// @returns input parser object for given json abi
/// TODO: refactor creating the parser, do not double logic from contract
/**
* 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) {
@ -170,8 +209,13 @@ var inputParser = function (json) {
return parser;
};
/// @param json abi for contract
/// @returns output parser for given json abi
/**
* 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) {

161
libjsqrc/ethereumjs/lib/formatters.js → libjsqrc/ethereumjs/lib/solidity/formatters.js

@ -24,74 +24,93 @@ if (process.env.NODE_ENV !== 'build') {
var BigNumber = require('bignumber.js'); // jshint ignore:line
}
var utils = require('./utils');
var c = require('./const');
/// @param string string to be padded
/// @param number of characters that result string should have
/// @param sign, by default 0
/// @returns right aligned string
var utils = require('../utils/utils');
var c = require('../utils/config');
/**
* 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;
};
/// Formats input value to byte representation of int
/// If value is negative, return it's two's complement
/// If the value is floating point, round it down
/// @returns right-aligned byte representation of int
/**
* 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) {
/*jshint maxcomplexity:7 */
var padding = c.ETH_PADDING * 2;
if (value instanceof BigNumber || typeof value === 'number') {
if (typeof value === 'number')
value = new BigNumber(value);
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
value = value.round();
if (value.lessThan(0))
value = new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(value).plus(1);
value = value.toString(16);
}
else if (value.indexOf('0x') === 0)
value = value.substr(2);
else if (typeof value === 'string')
value = formatInputInt(new BigNumber(value));
else
value = (+value).toString(16);
return padLeft(value, padding);
BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
return padLeft(utils.toTwosComplement(value).round().toString(16), padding);
};
/// Formats input value to byte representation of string
/// @returns left-algined byte representation of string
/**
* 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
/// @returns right-aligned byte representation bool
/**
* 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
/// @returns byte representation of real
/**
* 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
/// @param value is hex format
/// @returns true if it is negative, otherwise false
/**
* 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 input right-aligned input bytes to int
/// @returns right-aligned input bytes formatted to int
/**
* 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)) {
@ -100,44 +119,84 @@ var formatOutputInt = function (value) {
return new BigNumber(value, 16);
};
/// Formats big right-aligned input bytes to uint
/// @returns right-aligned input bytes formatted to uint
/**
* 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);
};
/// @returns input bytes formatted to real
/**
* 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));
};
/// @returns input bytes formatted to ureal
/**
* 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));
};
/// @returns right-aligned input bytes formatted to hex
/**
* 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;
};
/// @returns right-aligned input bytes formatted to bool
/**
* 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;
};
/// @returns left-aligned input bytes formatted to ascii string
/**
* 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);
};
/// @returns right-aligned input bytes formatted to address
/**
* 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,

0
libjsqrc/ethereumjs/lib/types.js → libjsqrc/ethereumjs/lib/solidity/types.js

143
libjsqrc/ethereumjs/lib/utils.js

@ -1,143 +0,0 @@
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file utils.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
var c = require('./const');
/// Finds first index of array element matching pattern
/// @param array
/// @param callback pattern
/// @returns index of element
var findIndex = function (array, callback) {
var end = false;
var i = 0;
for (; i < array.length && !end; i++) {
end = callback(array[i]);
}
return end ? i - 1 : -1;
};
/// @returns ascii string representation of hex value prefixed with 0x
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;
};
var toHex = function(str) {
var hex = "";
for(var i = 0; i < str.length; i++) {
var n = str.charCodeAt(i).toString(16);
hex += n.length < 2 ? '0' + n : n;
}
return hex;
};
/// @returns hex representation (prefixed by 0x) of ascii string
var fromAscii = function(str, pad) {
pad = pad === undefined ? 0 : pad;
var hex = toHex(str);
while (hex.length < pad*2)
hex += "00";
return "0x" + hex;
};
/// @returns 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 function from input abi
/// @returns abi array with filtered objects of type 'function'
var filterFunctions = function (json) {
return json.filter(function (current) {
return current.type === 'function';
});
};
/// Filters all events form input abi
/// @returns abi array with filtered objects of type 'event'
var filterEvents = function (json) {
return json.filter(function (current) {
return current.type === 'event';
});
};
/// used to transform value/string to eth string
/// TODO: use BigNumber.js to parse int
/// TODO: add tests for it!
var toEth = function (str) {
/*jshint maxcomplexity:7 */
var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
var unit = 0;
var units = c.ETH_UNITS;
while (val > 3000 && unit < units.length - 1)
{
val /= 1000;
unit++;
}
var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2);
var replaceFunction = function($0, $1, $2) {
return $1 + ',' + $2;
};
while (true) {
var o = s;
s = s.replace(/(\d)(\d\d\d[\.\,])/, replaceFunction);
if (o === s)
break;
}
return s + ' ' + units[unit];
};
module.exports = {
findIndex: findIndex,
toAscii: toAscii,
fromAscii: fromAscii,
extractDisplayName: extractDisplayName,
extractTypeName: extractTypeName,
filterFunctions: filterFunctions,
filterEvents: filterEvents,
toEth: toEth
};

18
libjsqrc/ethereumjs/lib/const.js → libjsqrc/ethereumjs/lib/utils/config.js

@ -14,12 +14,25 @@
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file const.js
/** @file config.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
/**
* Utils
*
* @module utils
*/
/**
* Utility functions
*
* @class [utils] config
* @constructor
*/
/// required to define ETH_BIGNUMBER_ROUNDING_MODE
if (process.env.NODE_ENV !== 'build') {
var BigNumber = require('bignumber.js'); // jshint ignore:line
@ -52,6 +65,7 @@ module.exports = {
ETH_SIGNATURE_LENGTH: 4,
ETH_UNITS: ETH_UNITS,
ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
ETH_POLLING_TIMEOUT: 1000
ETH_POLLING_TIMEOUT: 1000,
ETH_DEFAULTBLOCK: 'latest'
};

448
libjsqrc/ethereumjs/lib/utils/utils.js

@ -0,0 +1,448 @@
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file utils.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
/**
* Utils
*
* @module utils
*/
/**
* Utility functions
*
* @class [utils] utils
* @constructor
*/
if (process.env.NODE_ENV !== 'build') {
var BigNumber = require('bignumber.js'); // jshint ignore:line
}
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'
};
/** 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 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) {
if (!isString(address)) {
return false;
}
return ((address.indexOf('0x') === 0 && address.length === 42) ||
(address.indexOf('0x') === -1 && address.length === 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;
};
module.exports = {
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,
isBigNumber: isBigNumber,
isAddress: isAddress,
isFunction: isFunction,
isString: isString,
isObject: isObject,
isBoolean: isBoolean,
isArray: isArray
};

201
libjsqrc/ethereumjs/lib/web3.js

@ -23,17 +23,16 @@
* @date 2014
*/
if (process.env.NODE_ENV !== 'build') {
var BigNumber = require('bignumber.js');
}
var eth = require('./eth');
var db = require('./db');
var shh = require('./shh');
var watches = require('./watches');
var filter = require('./filter');
var utils = require('./utils');
var requestManager = require('./requestmanager');
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('./solidity/formatters');
var requestManager = require('./web3/requestmanager');
var c = require('./utils/config');
/// @returns an array of objects describing web3 api methods
var web3Methods = function () {
@ -46,14 +45,53 @@ var web3Methods = function () {
/// setups api calls for these methods
var setupMethods = function (obj, methods) {
methods.forEach(function (method) {
obj[method.name] = function () {
var args = Array.prototype.slice.call(arguments);
var call = typeof method.call === 'function' ? method.call(args) : method.call;
return web3.manager.send({
method: call,
params: args
});
};
// allow for object methods 'myObject.method'
var objectMethods = method.name.split('.'),
callFunction = function () {
/*jshint maxcomplexity:8 */
var callback = null,
args = Array.prototype.slice.call(arguments),
call = typeof method.call === 'function' ? method.call(args) : method.call;
// get the callback if one is available
if(typeof args[args.length-1] === 'function'){
callback = args[args.length-1];
Array.prototype.pop.call(args);
}
// add the defaultBlock if not given
if(method.addDefaultblock) {
if(args.length !== method.addDefaultblock)
Array.prototype.push.call(args, (isFinite(c.ETH_DEFAULTBLOCK) ? utils.fromDecimal(c.ETH_DEFAULTBLOCK) : c.ETH_DEFAULTBLOCK));
else
args[args.length-1] = isFinite(args[args.length-1]) ? utils.fromDecimal(args[args.length-1]) : args[args.length-1];
}
// show deprecated warning
if(method.newMethod)
console.warn('This method is deprecated please use web3.'+ method.newMethod +'() instead.');
return web3.manager.send({
method: call,
params: args,
outputFormatter: method.outputFormatter,
inputFormatter: method.inputFormatter,
addDefaultblock: method.addDefaultblock
}, callback);
};
if(objectMethods.length > 1) {
if(!obj[objectMethods[0]])
obj[objectMethods[0]] = {};
obj[objectMethods[0]][objectMethods[1]] = callFunction;
} else {
obj[objectMethods[0]] = callFunction;
}
});
};
@ -63,20 +101,36 @@ var setupProperties = function (obj, properties) {
properties.forEach(function (property) {
var 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
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]
params: [val],
inputFormatter: property.inputFormatter
});
};
}
proto.enumerable = !property.newProperty;
Object.defineProperty(obj, property.name, proto);
});
};
@ -94,12 +148,12 @@ var stopPolling = function (id) {
};
var ethWatch = {
startPolling: startPolling.bind(null, 'eth_changed'),
startPolling: startPolling.bind(null, 'eth_getFilterChanges'),
stopPolling: stopPolling
};
var shhWatch = {
startPolling: startPolling.bind(null, 'shh_changed'),
startPolling: startPolling.bind(null, 'shh_getFilterChanges'),
stopPolling: stopPolling
};
@ -108,6 +162,19 @@ var web3 = {
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,
@ -115,23 +182,30 @@ var web3 = {
fromAscii: utils.fromAscii,
/// @returns decimal representaton of hex value prefixed by 0x
toDecimal: function (val) {
// remove 0x and place 0, if it's required
val = val.length > 2 ? val.substring(2) : "0";
return (new BigNumber(val, 16).toString(10));
},
toDecimal: utils.toDecimal,
/// @returns hex representation (prefixed by 0x) of decimal value
fromDecimal: function (val) {
return "0x" + (new BigNumber(val).toString(16));
fromDecimal: utils.fromDecimal,
/// @returns a BigNumber object
toBigNumber: utils.toBigNumber,
toWei: utils.toWei,
fromWei: utils.fromWei,
isAddress: utils.isAddress,
// provide network information
net: {
// peerCount:
},
/// used to transform value/string to eth string
toEth: utils.toEth,
/// 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';
@ -141,24 +215,22 @@ var web3 = {
};
},
canary: function (abi) {
return function(addr) {
// Default to address of Config. TODO: rremove prior to genesis.
addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
return addr;
};
},
/// @param filter may be a string, object or event
/// @param indexed is optional, this is an object with optional event indexed params
/// @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'...)
/// TODO: fix it, 4 params? no way
/*jshint maxparams:4 */
watch: function (fil, indexed, options, formatter) {
if (fil._isEvent) {
return fil(indexed, options);
}
return filter(fil, ethWatch, formatter);
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 */
},
@ -169,25 +241,36 @@ var web3 = {
/// 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) {
return filter(fil, shhWatch);
console.warn('shh.watch() is deprecated please use shh.filter() instead.');
return this.filter(fil);
}
},
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();
}
};
// 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());
setupMethods(web3.eth, eth.methods());
setupProperties(web3.eth, eth.properties());
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());

72
libjsqrc/ethereumjs/lib/contract.js → libjsqrc/ethereumjs/lib/web3/contract.js

@ -20,9 +20,9 @@
* @date 2014
*/
var web3 = require('./web3');
var abi = require('./abi');
var utils = require('./utils');
var web3 = require('../web3');
var abi = require('../solidity/abi');
var utils = require('../utils/utils');
var eventImpl = require('./event');
var signature = require('./signature');
@ -38,16 +38,24 @@ var exportNatspecGlobals = function (vars) {
var addFunctionRelatedPropertiesToContract = function (contract) {
contract.call = function (options) {
contract._isTransact = false;
contract._isTransaction = false;
contract._options = options;
return contract;
};
contract.transact = function (options) {
contract._isTransact = true;
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) {
@ -79,14 +87,14 @@ var addFunctionsToContract = function (contract, desc, address) {
options.to = address;
options.data = sign + parsed;
var isTransact = contract._isTransact === true || (contract._isTransact !== false && !method.constant);
var isTransaction = contract._isTransaction === true || (contract._isTransaction !== false && !method.constant);
var collapse = options.collapse !== false;
// reset
contract._options = {};
contract._isTransact = null;
contract._isTransaction = null;
if (isTransact) {
if (isTransaction) {
exportNatspecGlobals({
abi: desc,
@ -96,7 +104,7 @@ var addFunctionsToContract = function (contract, desc, address) {
});
// transactions do not have any output, cause we do not know, when they will be processed
web3.eth.transact(options);
web3.eth.sendTransaction(options);
return;
}
@ -128,7 +136,7 @@ var addEventRelatedPropertiesToContract = function (contract, desc, address) {
return parser(data);
};
Object.defineProperty(contract, 'topic', {
Object.defineProperty(contract, 'topics', {
get: function() {
return utils.filterEvents(desc).map(function (e) {
return signature.eventSignatureFromAscii(e.name);
@ -151,7 +159,7 @@ var addEventsToContract = function (contract, desc, address) {
var parser = eventImpl.outputParser(e);
return parser(data);
};
return web3.eth.watch(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
@ -181,24 +189,40 @@ var addEventsToContract = function (contract, desc, address) {
* outputs: [{name: 'd', type: 'string' }]
* }]; // contract abi
*
* var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object
* var MyContract = web3.eth.contract(abi); // creation of contract prototype
*
* var contractInstance = new MyContract('0x0123123121');
*
* myContract.myMethod('this is test string param for call'); // myMethod call (implicit, default)
* myContract.call().myMethod('this is test string param for call'); // myMethod call (explicit)
* myContract.transact().myMethod('this is test string param for transact'); // myMethod transact
* 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 address - address of the contract, which should be called
* @param desc - abi json description of the contract, which is being created
* @param abi - abi json description of the contract, which is being created
* @returns contract object
*/
var contract = function (abi) {
var contract = function (address, desc) {
// 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]);
}
};
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?
desc.forEach(function (method) {
abi.forEach(function (method) {
if (method.name.indexOf('(') === -1) {
var displayName = method.name;
var typeName = method.inputs.map(function(i){return i.type; }).join();
@ -208,12 +232,12 @@ var contract = function (address, desc) {
var result = {};
addFunctionRelatedPropertiesToContract(result);
addFunctionsToContract(result, desc, address);
addEventRelatedPropertiesToContract(result, desc, address);
addEventsToContract(result, desc, address);
addFunctionsToContract(result, abi, address);
addEventRelatedPropertiesToContract(result, abi, address);
addEventsToContract(result, abi, address);
return result;
};
}
module.exports = contract;

0
libjsqrc/ethereumjs/lib/db.js → libjsqrc/ethereumjs/lib/web3/db.js

148
libjsqrc/ethereumjs/lib/web3/eth.js

@ -0,0 +1,148 @@
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file eth.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
/**
* Web3
*
* @module web3
*/
/**
* Eth methods and properties
*
* An example method object can look as follows:
*
* {
* name: 'getBlock',
* call: blockCall,
* 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
* ]
* },
*
* @class [web3] eth
* @constructor
*/
var formatters = require('./formatters');
var utils = require('../utils/utils');
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 methods = [
{ name: 'getBalance', call: 'eth_getBalance', addDefaultblock: 2,
outputFormatter: formatters.convertToBigNumber},
{ name: 'getStorage', call: 'eth_getStorage', addDefaultblock: 2},
{ name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3,
inputFormatter: utils.toHex},
{ name: 'getData', call: 'eth_getData', 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', inputFormatter: utils.toHex },
{ 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.getData' },
{ 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' }
];
/// @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'}
];
module.exports = {
methods: methods,
properties: properties
};

18
libjsqrc/ethereumjs/lib/event.js → libjsqrc/ethereumjs/lib/web3/event.js

@ -20,8 +20,8 @@
* @date 2014
*/
var abi = require('./abi');
var utils = require('./utils');
var abi = require('../solidity/abi');
var utils = require('../utils/utils');
var signature = require('./signature');
/// filter inputs array && returns only indexed (or not) inputs
@ -63,14 +63,14 @@ var indexedParamsToTopics = function (event, indexed) {
var inputParser = function (address, sign, event) {
// valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.watch'
// valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.filter'
return function (indexed, options) {
var o = options || {};
o.address = address;
o.topic = [];
o.topic.push(sign);
o.topics = [];
o.topics.push(sign);
if (indexed) {
o.topic = o.topic.concat(indexedParamsToTopics(event, indexed));
o.topics = o.topics.concat(indexedParamsToTopics(event, indexed));
}
return o;
};
@ -102,12 +102,12 @@ var outputParser = function (event) {
};
output.topics = output.topic; // fallback for go-ethereum
if (!output.topic) {
if (!output.topics) {
return result;
}
var indexedOutputs = filterInputs(event.inputs, true);
var indexedData = "0x" + output.topic.slice(1, output.topic.length).map(function (topic) { return topic.slice(2); }).join("");
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);
@ -122,7 +122,7 @@ var outputParser = function (event) {
var getMatchingEvent = function (events, payload) {
for (var i = 0; i < events.length; i++) {
var sign = signature.eventSignatureFromAscii(events[i].name);
if (sign === payload.topic[0]) {
if (sign === payload.topics[0]) {
return events[i];
}
}

104
libjsqrc/ethereumjs/lib/filter.js → libjsqrc/ethereumjs/lib/web3/filter.js

@ -23,12 +23,14 @@
* @date 2014
*/
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.getMessages === 'function' &&
typeof i.getLogs === 'function' &&
typeof i.uninstallFilter === 'function' &&
typeof i.startPolling === 'function' &&
typeof i.stopPolling === 'function';
@ -38,25 +40,56 @@ var implementationIsValid = function (i) {
/// @param should be string or object
/// @returns options string or object
var getOptions = function (options) {
/*jshint maxcomplexity:9 */
if (typeof options === 'string') {
return options;
}
options = options || {};
if (options.topics) {
console.warn('"topics" is deprecated, is "topic" instead');
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;
}
if (options.skip) {
console.warn('"skip" is deprecated, is "offset" instead');
options.offset = options.skip;
}
if (options.max) {
console.warn('"max" is deprecated, is "limit" instead');
options.limit = options.max;
}
// make sure topics, get converted to hex
if(options.topics instanceof Array) {
options.topics = options.topics.map(function(topic){
return utils.toHex(topic);
});
}
// evaluate lazy properties
return {
fromBlock: utils.toHex(options.fromBlock),
toBlock: utils.toHex(options.toBlock),
limit: utils.toHex(options.limit),
offset: utils.toHex(options.offset),
to: options.to,
topic: options.topic,
earliest: options.earliest,
latest: options.latest,
max: options.max,
skip: options.skip,
address: options.address
address: options.address,
topics: options.topics
};
};
@ -74,6 +107,8 @@ var filter = function(options, implementation, formatter) {
options = getOptions(options);
var callbacks = [];
var filterId = implementation.newFilter(options);
// call the callbacks
var onMessages = function (messages) {
messages.forEach(function (message) {
message = formatter ? formatter(message) : message;
@ -85,27 +120,54 @@ var filter = function(options, implementation, formatter) {
implementation.startPolling(filterId, onMessages, implementation.uninstallFilter);
var changed = function (callback) {
var watch = function(callback) {
callbacks.push(callback);
};
var messages = function () {
return implementation.getMessages(filterId);
};
var uninstall = function () {
var stopWatching = function() {
implementation.stopPolling(filterId);
implementation.uninstallFilter(filterId);
callbacks = [];
};
var get = function () {
var results = implementation.getLogs(filterId);
return utils.isArray(results) ? results.map(function(message){
return formatter ? formatter(message) : message;
}) : results;
};
return {
changed: changed,
arrived: changed,
happened: changed,
messages: messages,
logs: messages,
uninstall: uninstall
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);
}
};
};

203
libjsqrc/ethereumjs/lib/web3/formatters.js

@ -0,0 +1,203 @@
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file formatters.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* Fabian Vogelsteller <fabian@ethdev.com>
* @date 2015
*/
var utils = require('../utils/utils');
/**
* Should the input to a big number
*
* @method convertToBigNumber
* @param {String|Number|BigNumber}
* @returns {BigNumber} object
*/
var convertToBigNumber = function (value) {
return utils.toBigNumber(value);
};
/**
* 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'].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.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
*
* @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(block.transactions instanceof Array) {
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){
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(!(post.topics instanceof Array))
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(post.payload.indexOf('{') === 0 || post.payload.indexOf('[') === 0) {
try {
post.payload = JSON.parse(post.payload);
} catch (e) { }
}
// format the following options
post.topics = post.topics.map(function(topic){
return utils.toAscii(topic);
});
return post;
};
module.exports = {
convertToBigNumber: convertToBigNumber,
inputTransactionFormatter: inputTransactionFormatter,
outputTransactionFormatter: outputTransactionFormatter,
inputCallFormatter: inputCallFormatter,
outputBlockFormatter: outputBlockFormatter,
outputLogFormatter: outputLogFormatter,
inputPostFormatter: inputPostFormatter,
outputPostFormatter: outputPostFormatter
};

47
libjsqrc/ethereumjs/lib/httpsync.js → libjsqrc/ethereumjs/lib/web3/httpprovider.js

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file httpsync.js
/** @file httpprovider.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* Marian Oancea <marian@ethdev.com>
@ -25,24 +25,45 @@ if (process.env.NODE_ENV !== 'build') {
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
}
var HttpSyncProvider = function (host) {
var HttpProvider = function (host) {
this.name = 'HTTP';
this.handlers = [];
this.host = host || 'http://127.0.0.1:8080';
this.host = host || 'http://localhost:8080';
};
HttpSyncProvider.prototype.send = function (payload) {
//var data = formatJsonRpcObject(payload);
HttpProvider.prototype.send = function (payload, callback) {
var request = new XMLHttpRequest();
request.open('POST', this.host, false);
request.send(JSON.stringify(payload));
var result = request.responseText;
// check request.status
if(request.status !== 200)
return;
return JSON.parse(result);
// 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, true);
request.send(JSON.stringify(payload));
// SYNC
} else {
request.open('POST', this.host, false);
request.send(JSON.stringify(payload));
// check request.status
if(request.status !== 200)
return;
return JSON.parse(request.responseText);
}
};
module.exports = HttpSyncProvider;
module.exports = HttpProvider;

0
libjsqrc/ethereumjs/lib/jsonrpc.js → libjsqrc/ethereumjs/lib/web3/jsonrpc.js

41
libjsqrc/ethereumjs/lib/web3/net.js

@ -0,0 +1,41 @@
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file eth.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/
var utils = require('../utils/utils');
/// @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 },
];
module.exports = {
methods: methods,
properties: properties
};

0
libjsqrc/ethereumjs/lib/qtsync.js → libjsqrc/ethereumjs/lib/web3/qtsync.js

161
libjsqrc/ethereumjs/lib/web3/requestmanager.js

@ -0,0 +1,161 @@
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file requestmanager.js
* @authors:
* Jeffrey Wilcke <jeff@ethdev.com>
* Marek Kotewicz <marek@ethdev.com>
* Marian Oancea <marian@ethdev.com>
* Gav Wood <g@ethdev.com>
* @date 2014
*/
var jsonrpc = require('./jsonrpc');
var c = require('../utils/config');
/**
* 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
*/
var requestManager = function() {
var polls = [];
var timeout = null;
var provider;
var send = function (data, callback) {
/*jshint maxcomplexity: 8 */
// 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;
});
// 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];
});
}
var payload = jsonrpc.toPayload(data.method, data.params);
if (!provider) {
console.error('provider is not set');
return null;
}
// 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);
});
// SYNC
} else {
var result = provider.send(payload);
if (!jsonrpc.isValidResponse(result)) {
console.log(result);
if(typeof result === 'object' && result.error && result.error.message)
console.error(result.error.message);
return null;
}
// format the output
return (typeof data.outputFormatter === 'function') ? data.outputFormatter(result.result) : result.result;
}
};
var setProvider = function (p) {
provider = p;
};
/*jshint maxparams:4 */
var startPolling = function (data, pollId, callback, uninstall) {
polls.push({data: data, id: pollId, callback: callback, uninstall: uninstall});
};
/*jshint maxparams:3 */
var stopPolling = function (pollId) {
for (var i = polls.length; i--;) {
var poll = polls[i];
if (poll.id === pollId) {
polls.splice(i, 1);
}
}
};
var reset = function () {
polls.forEach(function (poll) {
poll.uninstall(poll.id);
});
polls = [];
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
poll();
};
var poll = function () {
polls.forEach(function (data) {
// send async
send(data.data, function(result){
if (!(result instanceof Array) || result.length === 0) {
return;
}
data.callback(result);
});
});
timeout = setTimeout(poll, c.ETH_POLLING_TIMEOUT);
};
poll();
return {
send: send,
setProvider: setProvider,
startPolling: startPolling,
stopPolling: stopPolling,
reset: reset
};
};
module.exports = requestManager;

11
libjsqrc/ethereumjs/lib/shh.js → libjsqrc/ethereumjs/lib/web3/shh.js

@ -20,14 +20,19 @@
* @date 2015
*/
var formatters = require('./formatters');
/// @returns an array of objects describing web3.shh api methods
var methods = function () {
return [
{ name: 'post', call: 'shh_post' },
{ name: 'post', call: 'shh_post', inputFormatter: formatters.inputPostFormatter },
{ name: 'newIdentity', call: 'shh_newIdentity' },
{ name: 'haveIdentity', call: 'shh_haveIdentity' },
{ name: 'hasIdentity', call: 'shh_hasIdentity' },
{ name: 'newGroup', call: 'shh_newGroup' },
{ name: 'addToGroup', call: 'shh_addToGroup' }
{ name: 'addToGroup', call: 'shh_addToGroup' },
// deprecated
{ name: 'haveIdentity', call: 'shh_haveIdentity', newMethod: 'shh.hasIdentity' },
];
};

4
libjsqrc/ethereumjs/lib/signature.js → libjsqrc/ethereumjs/lib/web3/signature.js

@ -20,8 +20,8 @@
* @date 2015
*/
var web3 = require('./web3');
var c = require('./const');
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

8
libjsqrc/ethereumjs/lib/watches.js → libjsqrc/ethereumjs/lib/web3/watches.js

@ -20,16 +20,16 @@
* @date 2015
*/
/// @returns an array of objects describing web3.eth.watch api methods
/// @returns an array of objects describing web3.eth.filter api methods
var eth = function () {
var newFilter = function (args) {
return typeof args[0] === 'string' ? 'eth_newFilterString' : 'eth_newFilter';
return typeof args[0] === 'string' ? 'eth_newBlockFilter' : 'eth_newFilter';
};
return [
{ name: 'newFilter', call: newFilter },
{ name: 'uninstallFilter', call: 'eth_uninstallFilter' },
{ name: 'getMessages', call: 'eth_filterLogs' }
{ name: 'getLogs', call: 'eth_getFilterLogs' }
];
};
@ -38,7 +38,7 @@ var shh = function () {
return [
{ name: 'newFilter', call: 'shh_newFilter' },
{ name: 'uninstallFilter', call: 'shh_uninstallFilter' },
{ name: 'getMessages', call: 'shh_getMessages' }
{ name: 'getLogs', call: 'shh_getMessages' }
];
};

7
libjsqrc/ethereumjs/package-init.js

@ -0,0 +1,7 @@
/* jshint ignore:start */
if(typeof web3 === 'undefined') {
web3 = require('web3');
}
/* jshint ignore:end */

29
libjsqrc/ethereumjs/package.js

@ -0,0 +1,29 @@
/* jshint ignore:start */
Package.describe({
name: 'ethereum:js',
version: '0.1.1',
summary: 'Ethereum JavaScript API, middleware to talk to a ethreum node over RPC',
git: 'https://github.com/ethereum/ethereum.js',
// By default, Meteor will default to using README.md for documentation.
// To avoid submitting documentation, set this field to null.
documentation: 'README.md'
});
Package.onUse(function(api) {
api.versionsFrom('1.0.3.2');
api.use('3stack:bignumber@2.0.0', 'client');
api.export('BigNumber', 'client');
api.export('web3', 'client');
api.addFiles('dist/ethereum.js', 'client');
api.addFiles('package-init.js', 'client');
});
// Package.onTest(function(api) {
// api.use('tinytest');
// api.use('test');
// api.addFiles('test-tests.js');
// });
/* jshint ignore:end */

39
libjsqrc/ethereumjs/package.json

@ -1,22 +1,24 @@
{
"name": "ethereum.js",
"namespace": "ethereum",
"version": "0.0.16",
"description": "Ethereum Compatible JavaScript API",
"version": "0.1.1",
"description": "Ethereum JavaScript API, middleware to talk to a ethreum node over RPC",
"main": "./index.js",
"directories": {
"lib": "./lib"
},
"dependencies": {
"bignumber.js": ">=2.0.0",
"envify": "^3.0.0",
"unreachable-branch-transform": "^0.1.0",
"xmlhttprequest": "*"
},
"devDependencies": {
"bower": ">=1.3.0",
"browserify": ">=6.0",
"chai": "^2.1.1",
"coveralls": "^2.11.2",
"del": ">=0.1.1",
"envify": "^3.0.0",
"exorcist": "^0.1.6",
"gulp": ">=3.4.0",
"gulp-jshint": ">=1.5.0",
@ -25,17 +27,22 @@
"gulp-uglify": ">=1.0.0",
"istanbul": "^0.3.5",
"jshint": ">=2.5.0",
"karma": "^0.12.31",
"karma-browserify": "^4.0.0",
"karma-chrome-launcher": "^0.1.7",
"karma-firefox-launcher": "^0.1.4",
"karma-mocha": "^0.1.10",
"karma-safari-launcher": "^0.1.1",
"mocha": ">=2.1.0",
"mocha-lcov-reporter": "0.0.1",
"unreachable-branch-transform": "^0.1.0",
"vinyl-source-stream": "^1.0.0"
},
"scripts": {
"build": "gulp",
"watch": "gulp watch",
"lint": "gulp lint",
"lint": "jshint *.js lib",
"test": "mocha",
"test-coveralls": "istanbul cover _mocha -- -R spec && cat coverage/lcov.info | coveralls --verbose"
"test-coveralls": "istanbul cover _mocha -- -R spec && cat coverage/lcov.info | coveralls --verbose",
"karma": "./node_modules/karma/bin/karma start --singleRun=true --browsers=\"Firefox\""
},
"repository": {
"type": "git",
@ -45,6 +52,19 @@
"bugs": {
"url": "https://github.com/ethereum/ethereum.js/issues"
},
"browserify": {
"transform": [
[
"envify",
{
"NODE_ENV": "build"
}
],
[
"unreachable-branch-transform"
]
]
},
"keywords": [
"ethereum",
"javascript",
@ -66,6 +86,11 @@
"name": "Marian Oancea",
"email": "marian@ethdev.com",
"url": "https://github.com/cubedro"
},
{
"name": "Fabian Vogelsteller",
"email": "fabian@ethdev.com",
"homepage": "https://github.com/frozeman"
}
],
"license": "LGPL-3.0"

18
libjsqrc/ethereumjs/test/abi.inputParser.js

@ -1,6 +1,6 @@
var assert = require('assert');
var BigNumber = require('bignumber.js');
var abi = require('../lib/abi.js');
var abi = require('../lib/solidity/abi.js');
var clone = function (object) { return JSON.parse(JSON.stringify(object)); };
var description = [{
@ -544,5 +544,21 @@ describe('abi', function() {
});
it('should throw an incorrect type error', function () {
// given
var d = clone(description);
d[0].inputs = [
{ type: 'uin' }
]
// when
var parser = abi.inputParser(d);
// then
assert.throws(function () {parser.test('0x')}, Error);
});
});
});

18
libjsqrc/ethereumjs/test/abi.outputParser.js

@ -1,6 +1,6 @@
var assert = require('assert');
var BigNumber = require('bignumber.js');
var abi = require('../lib/abi.js');
var abi = require('../lib/solidity/abi.js');
var clone = function (object) { return JSON.parse(JSON.stringify(object)); };
var description = [{
@ -456,6 +456,22 @@ describe('abi', function() {
});
it('should throw an incorrect type error', function () {
// given
var d = clone(description);
d[0].outputs = [
{ type: 'uin' }
]
// when
var parser = abi.outputParser(d);
// then
assert.throws(function () {parser.test('0x')}, Error);
});
});
});

48
libjsqrc/ethereumjs/test/eth.contract.js

@ -1,5 +1,5 @@
var assert = require('assert');
var contract = require('../lib/contract.js');
var contract = require('../lib/web3/contract.js');
describe('contract', function() {
it('should create simple contract with one method from abi with explicit type name', function () {
@ -22,11 +22,12 @@ describe('contract', function() {
}];
// when
var con = contract(null, description);
var Con = contract(description);
var myCon = new Con(null);
// then
assert.equal('function', typeof con.test);
assert.equal('function', typeof con.test['uint256']);
assert.equal('function', typeof myCon.test);
assert.equal('function', typeof myCon.test['uint256']);
});
it('should create simple contract with one method from abi with implicit type name', function () {
@ -49,11 +50,12 @@ describe('contract', function() {
}];
// when
var con = contract(null, description);
var Con = contract(description);
var myCon = new Con(null);
// then
assert.equal('function', typeof con.test);
assert.equal('function', typeof con.test['uint256']);
assert.equal('function', typeof myCon.test);
assert.equal('function', typeof myCon.test['uint256']);
});
it('should create contract with multiple methods', function () {
@ -90,13 +92,14 @@ describe('contract', function() {
}];
// when
var con = contract(null, description);
var Con = contract(description);
var myCon = new Con(null);
// then
assert.equal('function', typeof con.test);
assert.equal('function', typeof con.test['uint256']);
assert.equal('function', typeof con.test2);
assert.equal('function', typeof con.test2['uint256']);
assert.equal('function', typeof myCon.test);
assert.equal('function', typeof myCon.test['uint256']);
assert.equal('function', typeof myCon.test2);
assert.equal('function', typeof myCon.test2['uint256']);
});
it('should create contract with overloaded methods', function () {
@ -133,12 +136,13 @@ describe('contract', function() {
}];
// when
var con = contract(null, description);
var Con = contract(description);
var myCon = new Con(null);
// then
assert.equal('function', typeof con.test);
assert.equal('function', typeof con.test['uint256']);
assert.equal('function', typeof con.test['string']);
assert.equal('function', typeof myCon.test);
assert.equal('function', typeof myCon.test['uint256']);
assert.equal('function', typeof myCon.test['string']);
});
it('should create contract with no methods', function () {
@ -161,10 +165,11 @@ describe('contract', function() {
// when
var con = contract(null, description);
var Con = contract(description);
var myCon = new Con(null);
// then
assert.equal('undefined', typeof con.test);
assert.equal('undefined', typeof myCon.test);
});
@ -189,11 +194,12 @@ describe('contract', function() {
// when
var con = contract(null, description);
var Con = contract(description);
var myCon = new Con(null);
// then
assert.equal('function', typeof con.test);
assert.equal('function', typeof con.test['uint256']);
assert.equal('function', typeof myCon.test);
assert.equal('function', typeof myCon.test['uint256']);
});

61
libjsqrc/ethereumjs/test/eth.methods.js

@ -4,33 +4,56 @@ var u = require('./test.utils.js');
describe('web3', function() {
describe('eth', function() {
u.methodExists(web3.eth, 'balanceAt');
u.methodExists(web3.eth, 'stateAt');
u.methodExists(web3.eth, 'storageAt');
u.methodExists(web3.eth, 'countAt');
u.methodExists(web3.eth, 'codeAt');
u.methodExists(web3.eth, 'transact');
u.methodExists(web3.eth, 'getBalance');
u.methodExists(web3.eth, 'getStorageAt');
u.methodExists(web3.eth, 'getStorage');
u.methodExists(web3.eth, 'getTransactionCount');
u.methodExists(web3.eth, 'getData');
u.methodExists(web3.eth, 'sendTransaction');
u.methodExists(web3.eth, 'call');
u.methodExists(web3.eth, 'block');
u.methodExists(web3.eth, 'transaction');
u.methodExists(web3.eth, 'uncle');
u.methodExists(web3.eth, 'compilers');
u.methodExists(web3.eth, 'lll');
u.methodExists(web3.eth, 'solidity');
u.methodExists(web3.eth, 'serpent');
u.methodExists(web3.eth, 'logs');
u.methodExists(web3.eth, 'transactionCount');
u.methodExists(web3.eth, 'uncleCount');
u.methodExists(web3.eth, 'getBlock');
u.methodExists(web3.eth, 'getTransaction');
u.methodExists(web3.eth, 'getUncle');
u.methodExists(web3.eth, 'getCompilers');
u.methodExists(web3.eth.compile, 'lll');
u.methodExists(web3.eth.compile, 'solidity');
u.methodExists(web3.eth.compile, 'serpent');
u.methodExists(web3.eth, 'getBlockTransactionCount');
u.methodExists(web3.eth, 'getBlockUncleCount');
u.methodExists(web3.eth, 'filter');
u.methodExists(web3.eth, 'contract');
u.propertyExists(web3.eth, 'coinbase');
u.propertyExists(web3.eth, 'listening');
u.propertyExists(web3.eth, 'mining');
u.propertyExists(web3.eth, 'gasPrice');
u.propertyExists(web3.eth, 'accounts');
u.propertyExists(web3.eth, 'peerCount');
u.propertyExists(web3.eth, 'defaultBlock');
u.propertyExists(web3.eth, 'number');
u.propertyExists(web3.eth, 'blockNumber');
});
// Fail at the moment
// describe('eth', function(){
// it('should be a positive balance', function() {
// // when
// var testAddress = '0x50f4ed0e83f9da907017bcfb444e3e25407f59bb';
// var balance = web3.eth.balanceAt(testAddress);
// // then
// assert(balance > 0, 'Balance is ' + balance);
// });
// it('should return a block', function() {
// // when
// var block = web3.eth.block(0);
// // then
// assert.notEqual(block, null);
// assert.equal(block.number, 0);
// assert(web3.toDecimal(block.difficulty) > 0);
// });
// });
});

50
libjsqrc/ethereumjs/test/event.inputParser.js

@ -1,6 +1,6 @@
var assert = require('assert');
var event = require('../lib/event.js');
var f = require('../lib/formatters.js');
var event = require('../lib/web3/event.js');
var f = require('../lib/solidity/formatters.js');
describe('event', function () {
describe('inputParser', function () {
@ -20,8 +20,8 @@ describe('event', function () {
// then
assert.equal(result.address, address);
assert.equal(result.topic.length, 1);
assert.equal(result.topic[0], signature);
assert.equal(result.topics.length, 1);
assert.equal(result.topics[0], signature);
});
@ -31,10 +31,10 @@ describe('event', function () {
var address = '0x012345';
var signature = '0x987654';
var options = {
earliest: 1,
latest: 2,
fromBlock: 1,
toBlock: 2,
offset: 3,
max: 4
limit: 4
};
var e = {
name: 'Event',
@ -47,12 +47,12 @@ describe('event', function () {
// then
assert.equal(result.address, address);
assert.equal(result.topic.length, 1);
assert.equal(result.topic[0], signature);
assert.equal(result.earliest, options.earliest);
assert.equal(result.latest, options.latest);
assert.equal(result.topics.length, 1);
assert.equal(result.topics[0], signature);
assert.equal(result.fromBlock, options.fromBlock);
assert.equal(result.toBlock, options.toBlock);
assert.equal(result.offset, options.offset);
assert.equal(result.max, options.max);
assert.equal(result.limit, options.limit);
});
@ -62,10 +62,10 @@ describe('event', function () {
var address = '0x012345';
var signature = '0x987654';
var options = {
earliest: 1,
latest: 2,
fromBlock: 1,
toBlock: 2,
offset: 3,
max: 4
limit: 4
};
var e = {
name: 'Event',
@ -78,13 +78,13 @@ describe('event', function () {
// then
assert.equal(result.address, address);
assert.equal(result.topic.length, 2);
assert.equal(result.topic[0], signature);
assert.equal(result.topic[1], f.formatInputInt(4));
assert.equal(result.earliest, options.earliest);
assert.equal(result.latest, options.latest);
assert.equal(result.topics.length, 2);
assert.equal(result.topics[0], signature);
assert.equal(result.topics[1], f.formatInputInt(4));
assert.equal(result.fromBlock, options.fromBlock);
assert.equal(result.toBlock, options.toBlock);
assert.equal(result.offset, options.offset);
assert.equal(result.max, options.max);
assert.equal(result.limit, options.limit);
});
@ -110,10 +110,10 @@ describe('event', function () {
// then
assert.equal(result.address, address);
assert.equal(result.topic.length, 2);
assert.equal(result.topic[0], signature);
assert.equal(result.topic[1][0], f.formatInputInt(4));
assert.equal(result.topic[1][1], f.formatInputInt(69));
assert.equal(result.topics.length, 2);
assert.equal(result.topics[0], signature);
assert.equal(result.topics[1][0], f.formatInputInt(4));
assert.equal(result.topics[1][1], f.formatInputInt(69));
assert.equal(result.earliest, options.earliest);
assert.equal(result.latest, options.latest);
assert.equal(result.offset, options.offset);

2
libjsqrc/ethereumjs/test/event.outputParser.js

@ -1,5 +1,5 @@
var assert = require('assert');
var event = require('../lib/event.js');
var event = require('../lib/web3/event.js');
describe('event', function () {
describe('outputParser', function () {

13
libjsqrc/ethereumjs/test/filter.methods.js

@ -1,11 +1,11 @@
var assert = require('assert');
var filter = require('../lib/filter');
var filter = require('../lib/web3/filter');
var u = require('./test.utils.js');
var empty = function () {};
var implementation = {
newFilter: empty,
getMessages: empty,
getLogs: empty,
uninstallFilter: empty,
startPolling: empty,
stopPolling: empty,
@ -16,12 +16,9 @@ describe('web3', function () {
describe('filter', function () {
var f = filter({}, implementation);
u.methodExists(f, 'arrived');
u.methodExists(f, 'happened');
u.methodExists(f, 'changed');
u.methodExists(f, 'messages');
u.methodExists(f, 'logs');
u.methodExists(f, 'uninstall');
u.methodExists(f, 'watch');
u.methodExists(f, 'stopWatching');
u.methodExists(f, 'get');
});
});
});

28
libjsqrc/ethereumjs/test/formatters.inputPostFormatter.js

@ -0,0 +1,28 @@
var chai = require('chai');
var formatters = require('../lib/web3/formatters.js');
var assert = chai.assert;
describe('formatters', function () {
describe('inputPostFormatter', function () {
it('should return the correct value', function () {
// input as strings and numbers
assert.deepEqual(formatters.inputPostFormatter({
from: '0x00000',
to: '0x00000',
payload: {test: 'test'},
ttl: 200,
priority: 1000,
topics: ['hello','mytopics']
}), {
from: '0x00000',
to: '0x00000',
payload: '0x7b2274657374223a2274657374227d',
ttl: '0xc8',
priority: '0x3e8',
topics: ['0x68656c6c6f','0x6d79746f70696373']
});
});
});
});

26
libjsqrc/ethereumjs/test/formatters.inputTransactionFormatter.js

@ -0,0 +1,26 @@
var assert = require('assert');
var formatters = require('../lib/web3/formatters.js');
var BigNumber = require('bignumber.js');
describe('formatters', function () {
describe('inputTransactionFormatter', function () {
it('should return the correct value', function () {
assert.deepEqual(formatters.inputTransactionFormatter({
data: '0x34234kjh23kj4234',
value: new BigNumber(100),
from: '0x00000',
to: '0x00000',
gas: 1000,
gasPrice: new BigNumber(1000),
}), {
data: '0x34234kjh23kj4234',
value: '0x64',
from: '0x00000',
to: '0x00000',
gas: '0x3e8',
gasPrice: '0x3e8',
});
});
});
});

48
libjsqrc/ethereumjs/test/formatters.outputBlockFormatter.js

@ -0,0 +1,48 @@
var assert = require('assert');
var formatters = require('../lib/web3/formatters.js');
var BigNumber = require('bignumber.js');
describe('formatters', function () {
describe('outputBlockFormatter', function () {
it('should return the correct value', function () {
assert.deepEqual(formatters.outputBlockFormatter({
hash: '0x34234kjh23kj4234',
parentHash: '0x34234kjh23kj4234',
miner: '0x34234kjh23kj4234',
stateRoot: '0x34234kjh23kj4234',
sha3Uncles: '0x34234kjh23kj4234',
bloom: '0x34234kjh23kj4234',
difficulty: '0x3e8',
totalDifficulty: '0x3e8',
number: '0x3e8',
minGasPrice: '0x3e8',
gasLimit: '0x3e8',
gasUsed: '0x3e8',
timestamp: '0x3e8',
extraData: '0x34234kjh23kj4234',
nonce: '0x34234kjh23kj4234',
children: ['0x34234kjh23kj4234'],
size: '0x3e8'
}), {
hash: '0x34234kjh23kj4234',
parentHash: '0x34234kjh23kj4234',
miner: '0x34234kjh23kj4234',
stateRoot: '0x34234kjh23kj4234',
sha3Uncles: '0x34234kjh23kj4234',
bloom: '0x34234kjh23kj4234',
difficulty: new BigNumber(1000),
totalDifficulty: new BigNumber(1000),
number: 1000,
minGasPrice: new BigNumber(1000),
gasLimit: 1000,
gasUsed: 1000,
timestamp: 1000,
extraData: '0x34234kjh23kj4234',
nonce: '0x34234kjh23kj4234',
children: ['0x34234kjh23kj4234'],
size: 1000
});
});
});
});

27
libjsqrc/ethereumjs/test/formatters.outputLogFormatter.js

@ -0,0 +1,27 @@
var assert = require('assert');
var formatters = require('../lib/web3/formatters.js');
describe('formatters', function () {
describe('outputLogFormatter', function () {
it('should return the correct value', function () {
assert.deepEqual(formatters.outputLogFormatter({
transactionIndex: '0x3e8',
logIndex: '0x3e8',
blockNumber: '0x3e8',
transactionHash: '0x7b2274657374223a2274657374227d',
blockHash: '0x7b2274657374223a2274657374227d',
data: '0x7b2274657374223a2274657374227d',
topics: ['0x68656c6c6f','0x6d79746f70696373']
}), {
transactionIndex: 1000,
logIndex: 1000,
blockNumber: 1000,
transactionHash: '0x7b2274657374223a2274657374227d',
blockHash: '0x7b2274657374223a2274657374227d',
data: '0x7b2274657374223a2274657374227d',
topics: ['0x68656c6c6f','0x6d79746f70696373']
});
});
});
});

26
libjsqrc/ethereumjs/test/formatters.outputPostFormatter.js

@ -0,0 +1,26 @@
var assert = require('assert');
var formatters = require('../lib/web3/formatters.js');
describe('formatters', function () {
describe('outputPostFormatter', function () {
it('should return the correct value', function () {
assert.deepEqual(formatters.outputPostFormatter({
expiry: '0x3e8',
sent: '0x3e8',
ttl: '0x3e8',
workProved: '0x3e8',
payload: '0x7b2274657374223a2274657374227d',
topics: ['0x68656c6c6f','0x6d79746f70696373']
}), {
expiry: 1000,
sent: 1000,
ttl: 1000,
workProved: 1000,
payload: {test: 'test'},
payloadRaw: '0x7b2274657374223a2274657374227d',
topics: ['hello','mytopics']
});
});
});
});

26
libjsqrc/ethereumjs/test/formatters.outputTransactionFormatter.js

@ -0,0 +1,26 @@
var assert = require('assert');
var formatters = require('../lib/web3/formatters.js');
var BigNumber = require('bignumber.js');
describe('formatters', function () {
describe('outputTransactionFormatter', function () {
it('should return the correct value', function () {
assert.deepEqual(formatters.outputTransactionFormatter({
input: '0x34234kjh23kj4234',
from: '0x00000',
to: '0x00000',
value: '0x3e8',
gas: '0x3e8',
gasPrice: '0x3e8'
}), {
input: '0x34234kjh23kj4234',
from: '0x00000',
to: '0x00000',
value: new BigNumber(1000),
gas: 1000,
gasPrice: new BigNumber(1000),
});
});
});
});

2
libjsqrc/ethereumjs/test/jsonrpc.isValidResponse.js

@ -1,5 +1,5 @@
var assert = require('assert');
var jsonrpc = require('../lib/jsonrpc');
var jsonrpc = require('../lib/web3/jsonrpc');
describe('jsonrpc', function () {
describe('isValidResponse', function () {

2
libjsqrc/ethereumjs/test/jsonrpc.toBatchPayload.js

@ -1,5 +1,5 @@
var assert = require('assert');
var jsonrpc = require('../lib/jsonrpc');
var jsonrpc = require('../lib/web3/jsonrpc');
describe('jsonrpc', function () {
describe('toBatchPayload', function () {

2
libjsqrc/ethereumjs/test/jsonrpc.toPayload.js

@ -1,5 +1,5 @@
var assert = require('assert');
var jsonrpc = require('../lib/jsonrpc');
var jsonrpc = require('../lib/web3/jsonrpc');
describe('jsonrpc', function () {
describe('toPayload', function () {

10
libjsqrc/ethereumjs/test/net.methods.js

@ -0,0 +1,10 @@
var assert = require('assert');
var web3 = require('../index.js');
var u = require('./test.utils.js');
describe('web3', function() {
describe('net', function() {
u.propertyExists(web3.net, 'listening');
u.propertyExists(web3.net, 'peerCount');
});
});

3
libjsqrc/ethereumjs/test/shh.methods.js

@ -6,9 +6,10 @@ describe('web3', function() {
describe('shh', function() {
u.methodExists(web3.shh, 'post');
u.methodExists(web3.shh, 'newIdentity');
u.methodExists(web3.shh, 'haveIdentity');
u.methodExists(web3.shh, 'hasIdentity');
u.methodExists(web3.shh, 'newGroup');
u.methodExists(web3.shh, 'addToGroup');
u.methodExists(web3.shh, 'filter');
});
});

2
libjsqrc/ethereumjs/test/utils.extractDisplayName.js

@ -1,5 +1,5 @@
var assert = require('assert');
var utils = require('../lib/utils.js');
var utils = require('../lib/utils/utils.js');
describe('utils', function () {
describe('extractDisplayName', function () {

2
libjsqrc/ethereumjs/test/utils.extractTypeName.js

@ -1,5 +1,5 @@
var assert = require('assert');
var utils = require('../lib/utils.js');
var utils = require('../lib/utils/utils.js');
describe('utils', function () {
describe('extractTypeName', function () {

2
libjsqrc/ethereumjs/test/utils.filters.js

@ -1,5 +1,5 @@
var assert = require('assert');
var utils = require('../lib/utils.js');
var utils = require('../lib/utils/utils.js');
describe('utils', function() {
it('should filter functions and events from input array properly', function () {

43
libjsqrc/ethereumjs/test/utils.fromDecimal.js

@ -0,0 +1,43 @@
var chai = require('chai');
var utils = require('../lib/utils/utils.js');
var assert = chai.assert;
var tests = [
{ value: 1, expected: '0x1' },
{ value: '1', expected: '0x1' },
{ value: '0x1', expected: '0x1'},
{ value: '0x01', expected: '0x1'},
{ value: 15, expected: '0xf'},
{ value: '15', expected: '0xf'},
{ value: '0xf', expected: '0xf'},
{ value: '0x0f', expected: '0xf'},
{ value: -1, expected: '-0x1'},
{ value: '-1', expected: '-0x1'},
{ value: '-0x1', expected: '-0x1'},
{ value: '-0x01', expected: '-0x1'},
{ value: -15, expected: '-0xf'},
{ value: '-15', expected: '-0xf'},
{ value: '-0xf', expected: '-0xf'},
{ value: '-0x0f', expected: '-0xf'},
{ value: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'},
{ value: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
{ value: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'},
{ value: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
{ value: 0, expected: '0x0'},
{ value: '0', expected: '0x0'},
{ value: '0x0', expected: '0x0'},
{ value: -0, expected: '0x0'},
{ value: '-0', expected: '0x0'},
{ value: '-0x0', expected: '0x0'}
];
describe('utils', function () {
describe('fromDecimal', function () {
tests.forEach(function (test) {
it('should turn ' + test.value + ' to ' + test.expected, function () {
assert.equal(utils.fromDecimal(test.value), test.expected);
});
});
});
});

22
libjsqrc/ethereumjs/test/utils.fromWei.js

@ -0,0 +1,22 @@
var assert = require('assert');
var utils = require('../lib/utils/utils.js');
describe('utils', function () {
describe('fromWei', function () {
it('should return the correct value', function () {
assert.equal(utils.fromWei(1000000000000000000, 'wei'), '1000000000000000000');
assert.equal(utils.fromWei(1000000000000000000, 'kwei'), '1000000000000000');
assert.equal(utils.fromWei(1000000000000000000, 'mwei'), '1000000000000');
assert.equal(utils.fromWei(1000000000000000000, 'gwei'), '1000000000');
assert.equal(utils.fromWei(1000000000000000000, 'szabo'), '1000000');
assert.equal(utils.fromWei(1000000000000000000, 'finney'), '1000');
assert.equal(utils.fromWei(1000000000000000000, 'ether'), '1');
assert.equal(utils.fromWei(1000000000000000000, 'kether'), '0.001');
assert.equal(utils.fromWei(1000000000000000000, 'grand'), '0.001');
assert.equal(utils.fromWei(1000000000000000000, 'mether'), '0.000001');
assert.equal(utils.fromWei(1000000000000000000, 'gether'), '0.000000001');
assert.equal(utils.fromWei(1000000000000000000, 'tether'), '0.000000000001');
});
});
});

23
libjsqrc/ethereumjs/test/utils.isAddress.js

@ -0,0 +1,23 @@
var chai = require('chai');
var utils = require('../lib/utils/utils.js');
var assert = chai.assert;
var tests = [
{ value: function () {}, is: false},
{ value: new Function(), is: false},
{ value: 'function', is: false},
{ value: {}, is: false},
{ value: '0xc6d9d2cd449a754c494264e1809c50e34d64562b', is: true },
{ value: 'c6d9d2cd449a754c494264e1809c50e34d64562b', is: true }
];
describe('utils', function () {
describe('isAddress', function () {
tests.forEach(function (test) {
it('shoud test if value ' + test.value + ' is address: ' + test.is, function () {
assert.equal(utils.isAddress(test.value), test.is);
});
});
});
});

26
libjsqrc/ethereumjs/test/utils.isBigNumber.js

@ -0,0 +1,26 @@
var chai = require('chai');
var utils = require('../lib/utils/utils.js');
var BigNumber = require('bignumber.js');
var assert = chai.assert;
var tests = [
{ value: function () {}, is: false},
{ value: new Function(), is: false},
{ value: 'function', is: false},
{ value: {}, is: false},
{ value: new String('hello'), is: false},
{ value: new BigNumber(0), is: true},
{ value: 132, is: false},
{ value: '0x12', is: false},
];
describe('utils', function () {
describe('isBigNumber', function () {
tests.forEach(function (test) {
it('shoud test if value ' + test.func + ' is BigNumber: ' + test.is, function () {
assert.equal(utils.isBigNumber(test.value), test.is);
});
});
});
});

21
libjsqrc/ethereumjs/test/utils.isFunction.js

@ -0,0 +1,21 @@
var chai = require('chai');
var utils = require('../lib/utils/utils.js');
var assert = chai.assert;
var tests = [
{ func: function () {}, is: true},
{ func: new Function(), is: true},
{ func: 'function', is: false},
{ func: {}, is: false}
];
describe('utils', function () {
describe('isFunction', function () {
tests.forEach(function (test) {
it('shoud test if value ' + test.func + ' is function: ' + test.is, function () {
assert.equal(utils.isFunction(test.func), test.is);
});
});
});
});

22
libjsqrc/ethereumjs/test/utils.isString.js

@ -0,0 +1,22 @@
var chai = require('chai');
var utils = require('../lib/utils/utils.js');
var assert = chai.assert;
var tests = [
{ value: function () {}, is: false},
{ value: new Function(), is: false},
{ value: 'function', is: true},
{ value: {}, is: false},
{ value: new String('hello'), is: true}
];
describe('utils', function () {
describe('isString', function () {
tests.forEach(function (test) {
it('shoud test if value ' + test.func + ' is string: ' + test.is, function () {
assert.equal(utils.isString(test.value), test.is);
});
});
});
});

45
libjsqrc/ethereumjs/test/utils.toBigNumber.js

@ -0,0 +1,45 @@
var chai = require('chai');
var utils = require('../lib/utils/utils.js');
var BigNumber = require('bignumber.js');
var assert = chai.assert;
var tests = [
{ value: 1, expected: '1' },
{ value: '1', expected: '1' },
{ value: '0x1', expected: '1'},
{ value: '0x01', expected: '1'},
{ value: 15, expected: '15'},
{ value: '15', expected: '15'},
{ value: '0xf', expected: '15'},
{ value: '0x0f', expected: '15'},
{ value: new BigNumber('f', 16), expected: '15'},
{ value: -1, expected: '-1'},
{ value: '-1', expected: '-1'},
{ value: '-0x1', expected: '-1'},
{ value: '-0x01', expected: '-1'},
{ value: -15, expected: '-15'},
{ value: '-15', expected: '-15'},
{ value: '-0xf', expected: '-15'},
{ value: '-0x0f', expected: '-15'},
{ value: '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '115792089237316195423570985008687907853269984665640564039457584007913129639935'},
{ value: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '115792089237316195423570985008687907853269984665640564039457584007913129639933'},
{ value: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '-115792089237316195423570985008687907853269984665640564039457584007913129639935'},
{ value: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '-115792089237316195423570985008687907853269984665640564039457584007913129639933'},
{ value: 0, expected: '0'},
{ value: '0', expected: '0'},
{ value: '0x0', expected: '0'},
{ value: -0, expected: '0'},
{ value: '-0', expected: '0'},
{ value: '-0x0', expected: '0'},
{ value: new BigNumber(0), expected: '0'}
];
describe('utils', function () {
describe('toBigNumber', function () {
tests.forEach(function (test) {
it('should turn ' + test.value + ' to ' + test.expected, function () {
assert.equal(utils.toBigNumber(test.value).toString(10), test.expected);
});
});
});
});

14
libjsqrc/ethereumjs/test/utils.toDecimal.js

@ -0,0 +1,14 @@
var assert = require('assert');
var utils = require('../lib/utils/utils.js');
describe('utils', function () {
describe('toDecimal', function () {
it('should return the correct value', function () {
assert.equal(utils.toDecimal("0x3e8"), '1000');
// allow compatiblity
assert.equal(utils.toDecimal(100000), '100000');
assert.equal(utils.toDecimal('100000'), '100000');
});
});
});

42
libjsqrc/ethereumjs/test/utils.toHex.js

@ -0,0 +1,42 @@
var chai = require('chai');
var utils = require('../lib/utils/utils');
var BigNumber = require('bignumber.js');
var assert = chai.assert;
var tests = [
{ value: 1, expected: '0x1' },
{ value: '1', expected: '0x1' },
{ value: '0x1', expected: '0x1'},
{ value: '15', expected: '0xf'},
{ value: '0xf', expected: '0xf'},
{ value: -1, expected: '-0x1'},
{ value: '-1', expected: '-0x1'},
{ value: '-0x1', expected: '-0x1'},
{ value: '-15', expected: '-0xf'},
{ value: '-0xf', expected: '-0xf'},
{ value: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
{ value: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', expected: '-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'},
{ value: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd', expected: '-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd'},
{ value: 0, expected: '0x0'},
{ value: '0', expected: '0x0'},
{ value: '0x0', expected: '0x0'},
{ value: -0, expected: '0x0'},
{ value: '-0', expected: '0x0'},
{ value: '-0x0', expected: '0x0'},
{ value: [1,2,3,{test: 'data'}], expected: '0x5b312c322c332c7b2274657374223a2264617461227d5d'},
{ value: {test: 'test'}, expected: '0x7b2274657374223a2274657374227d'},
{ value: '{"test": "test"}', expected: '0x7b2274657374223a202274657374227d'},
{ value: 'myString', expected: '0x6d79537472696e67'},
{ value: new BigNumber(15), expected: '0xf'}
];
describe('utils', function () {
describe('toHex', function () {
tests.forEach(function (test) {
it('should turn ' + test.value + ' to ' + test.expected, function () {
assert.equal(utils.toHex(test.value), test.expected);
});
});
});
});

25
libjsqrc/ethereumjs/test/utils.toWei.js

@ -0,0 +1,25 @@
var chai = require('chai');
var utils = require('../lib/utils/utils');
var assert = chai.assert;
describe('utils', function () {
describe('toWei', function () {
it('should return the correct value', function () {
assert.equal(utils.toWei(1, 'wei'), '1');
assert.equal(utils.toWei(1, 'kwei'), '1000');
assert.equal(utils.toWei(1, 'mwei'), '1000000');
assert.equal(utils.toWei(1, 'gwei'), '1000000000');
assert.equal(utils.toWei(1, 'szabo'), '1000000000000');
assert.equal(utils.toWei(1, 'finney'), '1000000000000000');
assert.equal(utils.toWei(1, 'ether'), '1000000000000000000');
assert.equal(utils.toWei(1, 'kether'), '1000000000000000000000');
assert.equal(utils.toWei(1, 'grand'), '1000000000000000000000');
assert.equal(utils.toWei(1, 'mether'), '1000000000000000000000000');
assert.equal(utils.toWei(1, 'gether'), '1000000000000000000000000000');
assert.equal(utils.toWei(1, 'tether'), '1000000000000000000000000000000');
assert.throws(function () {utils.toWei(1, 'wei1');}, Error);
});
});
});

5
libjsqrc/ethereumjs/test/web3.methods.js

@ -8,7 +8,10 @@ describe('web3', function() {
u.methodExists(web3, 'fromAscii');
u.methodExists(web3, 'toDecimal');
u.methodExists(web3, 'fromDecimal');
u.methodExists(web3, 'toEth');
u.methodExists(web3, 'fromWei');
u.methodExists(web3, 'toWei');
u.methodExists(web3, 'toBigNumber');
u.methodExists(web3, 'isAddress');
u.methodExists(web3, 'setProvider');
u.methodExists(web3, 'reset');

2
libjsqrc/setup.js

@ -21,5 +21,5 @@
*/
var web3 = require('web3');
web3.setProvider(new web3.providers.HttpSyncProvider());
web3.setProvider(new web3.providers.HttpProvider());

1002
libweb3jsonrpc/WebThreeStubServerBase.cpp

File diff suppressed because it is too large

104
libweb3jsonrpc/WebThreeStubServerBase.h

@ -68,69 +68,63 @@ public:
WebThreeStubServerBase(jsonrpc::AbstractServerConnector& _conn, std::vector<dev::KeyPair> const& _accounts);
virtual std::string web3_sha3(std::string const& _param1);
virtual Json::Value eth_accounts();
virtual std::string eth_balanceAt(std::string const& _address);
virtual Json::Value eth_blockByHash(std::string const& _hash);
virtual Json::Value eth_blockByNumber(int _number);
virtual std::string eth_call(Json::Value const& _json);
virtual Json::Value eth_changed(int _id);
virtual std::string eth_codeAt(std::string const& _address);
virtual std::string net_peerCount();
virtual bool net_listening();
virtual std::string eth_coinbase();
virtual Json::Value eth_compilers();
virtual double eth_countAt(std::string const& _address);
virtual double eth_transactionCountByHash(std::string const& _hash);
virtual double eth_transactionCountByNumber(int _number);
virtual double eth_uncleCountByHash(std::string const& _hash);
virtual double eth_uncleCountByNumber(int _number);
virtual int eth_defaultBlock();
virtual bool eth_mining();
virtual std::string eth_gasPrice();
virtual Json::Value eth_filterLogs(int _id);
virtual Json::Value eth_accounts();
virtual std::string eth_blockNumber();
virtual std::string eth_getBalance(std::string const& _address, std::string const& _blockNumber);
virtual Json::Value eth_getStorage(std::string const& _address, std::string const& _blockNumber);
virtual std::string eth_getStorageAt(std::string const& _address, std::string const& _position, std::string const& _blockNumber);
virtual std::string eth_getTransactionCount(std::string const& _address, std::string const& _blockNumber);
virtual std::string eth_getBlockTransactionCountByHash(std::string const& _blockHash);
virtual std::string eth_getBlockTransactionCountByNumber(std::string const& _blockNumber);
virtual std::string eth_getUncleCountByBlockHash(std::string const& _blockHash);
virtual std::string eth_getUncleCountByBlockNumber(std::string const& _blockNumber);
virtual std::string eth_getData(std::string const& _address, std::string const& _blockNumber);
virtual std::string eth_sendTransaction(Json::Value const& _json);
virtual std::string eth_call(Json::Value const& _json, std::string const& _blockNumber);
virtual bool eth_flush();
virtual Json::Value eth_logs(Json::Value const& _json);
virtual bool eth_listening();
virtual bool eth_mining();
virtual int eth_newFilter(Json::Value const& _json);
virtual int eth_newFilterString(std::string const& _filter);
virtual int eth_number();
virtual int eth_peerCount();
virtual bool eth_setCoinbase(std::string const& _address);
virtual bool eth_setDefaultBlock(int _block);
virtual bool eth_setListening(bool _listening);
virtual std::string eth_lll(std::string const& _s);
virtual std::string eth_serpent(std::string const& _s);
virtual bool eth_setMining(bool _mining);
virtual std::string eth_solidity(std::string const& _code);
virtual std::string eth_stateAt(std::string const& _address, std::string const& _storage);
virtual Json::Value eth_storageAt(std::string const& _address);
virtual std::string eth_transact(Json::Value const& _json);
virtual Json::Value eth_transactionByHash(std::string const& _hash, int _i);
virtual Json::Value eth_transactionByNumber(int _number, int _i);
virtual Json::Value eth_uncleByHash(std::string const& _hash, int _i);
virtual Json::Value eth_uncleByNumber(int _number, int _i);
virtual bool eth_uninstallFilter(int _id);
virtual Json::Value eth_getBlockByHash(std::string const& _blockHash, bool _includeTransactions);
virtual Json::Value eth_getBlockByNumber(std::string const& _blockNumber, bool _includeTransactions);
virtual Json::Value eth_getTransactionByHash(std::string const& _transactionHash);
virtual Json::Value eth_getTransactionByBlockHashAndIndex(std::string const& _blockHash, std::string const& _transactionIndex);
virtual Json::Value eth_getTransactionByBlockNumberAndIndex(std::string const& _blockNumber, std::string const& _transactionIndex);
virtual Json::Value eth_getUncleByBlockHashAndIndex(std::string const& _blockHash, std::string const& _uncleIndex);
virtual Json::Value eth_getUncleByBlockNumberAndIndex(std::string const& _blockNumber, std::string const& _uncleIndex);
virtual Json::Value eth_getCompilers();
virtual std::string eth_compileLLL(std::string const& _s);
virtual std::string eth_compileSerpent(std::string const& _s);
virtual std::string eth_compileSolidity(std::string const& _code);
virtual std::string eth_newFilter(Json::Value const& _json);
virtual std::string eth_newBlockFilter(std::string const& _filter);
virtual bool eth_uninstallFilter(std::string const& _filterId);
virtual Json::Value eth_getFilterChanges(std::string const& _filterId);
virtual Json::Value eth_getFilterLogs(std::string const& _filterId);
virtual Json::Value eth_getLogs(Json::Value const& _json);
virtual Json::Value eth_getWork();
virtual bool eth_submitWork(std::string const& _nonce, std::string const& _mixHash);
virtual int eth_register(std::string const& _address);
virtual bool eth_unregister(int _id);
virtual Json::Value eth_queuedTransactions(int _id);
virtual std::string db_get(std::string const& _name, std::string const& _key);
virtual std::string db_getString(std::string const& _name, std::string const& _key);
virtual std::string eth_register(std::string const& _address);
virtual bool eth_unregister(std::string const& _accountId);
virtual Json::Value eth_fetchQueuedTransactions(std::string const& _accountId);
virtual bool db_put(std::string const& _name, std::string const& _key, std::string const& _value);
virtual bool db_putString(std::string const& _name, std::string const& _key, std::string const& _value);
virtual std::string db_get(std::string const& _name, std::string const& _key);
virtual std::string shh_addToGroup(std::string const& _group, std::string const& _who);
virtual Json::Value shh_changed(int _id);
virtual Json::Value shh_getMessages(int _id);
virtual bool shh_haveIdentity(std::string const& _id);
virtual int shh_newFilter(Json::Value const& _json);
virtual std::string shh_newGroup(std::string const& _id, std::string const& _who);
virtual std::string shh_newIdentity();
virtual bool shh_post(Json::Value const& _json);
virtual bool shh_uninstallFilter(int _id);
virtual std::string shh_newIdentity();
virtual bool shh_hasIdentity(std::string const& _identity);
virtual std::string shh_newGroup(std::string const& _id, std::string const& _who);
virtual std::string shh_addToGroup(std::string const& _group, std::string const& _who);
virtual std::string shh_newFilter(Json::Value const& _json);
virtual bool shh_uninstallFilter(std::string const& _filterId);
virtual Json::Value shh_getFilterChanges(std::string const& _filterId);
virtual Json::Value shh_getMessages(std::string const& _filterId);
void setAccounts(std::vector<dev::KeyPair> const& _accounts);
void setIdentities(std::vector<dev::KeyPair> const& _ids);
std::map<dev::Public, dev::Secret> const& ids() const { return m_ids; }

337
libweb3jsonrpc/abstractwebthreestubserver.h

@ -13,97 +13,84 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
AbstractWebThreeStubServer(jsonrpc::AbstractServerConnector &conn, jsonrpc::serverVersion_t type = jsonrpc::JSONRPC_SERVER_V2) : jsonrpc::AbstractServer<AbstractWebThreeStubServer>(conn, type)
{
this->bindAndAddMethod(jsonrpc::Procedure("web3_sha3", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::web3_sha3I);
this->bindAndAddMethod(jsonrpc::Procedure("net_peerCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::net_peerCountI);
this->bindAndAddMethod(jsonrpc::Procedure("net_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::net_listeningI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_coinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_coinbaseI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_setCoinbase", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_setCoinbaseI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_listening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_listeningI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_setListening", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_setListeningI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_mining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_miningI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_setMining", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_setMiningI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_gasPrice", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_gasPriceI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_accounts", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_accountsI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_peerCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_peerCountI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_defaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_defaultBlockI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_setDefaultBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_setDefaultBlockI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_number", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_numberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_balanceAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_balanceAtI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_stateAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_stateAtI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_storageAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_storageAtI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_countAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_countAtI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_transactionCountByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_transactionCountByHashI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_transactionCountByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_transactionCountByNumberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_uncleCountByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_uncleCountByHashI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_uncleCountByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uncleCountByNumberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_codeAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_codeAtI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_transact", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_transactI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_call", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_callI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_blockNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_blockNumberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getBalance", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getBalanceI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getStorage", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getStorageI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getStorageAt", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING,"param3",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getStorageAtI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getTransactionCount", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getTransactionCountI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getBlockTransactionCountByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getBlockTransactionCountByHashI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getBlockTransactionCountByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getBlockTransactionCountByNumberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getUncleCountByBlockHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getUncleCountByBlockHashI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getUncleCountByBlockNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getUncleCountByBlockNumberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getData", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getDataI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_sendTransaction", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_sendTransactionI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_call", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_callI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_flush", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_flushI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_blockByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_blockByHashI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_blockByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_blockByNumberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_transactionByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_transactionByHashI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_transactionByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_transactionByNumberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_uncleByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uncleByHashI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_uncleByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uncleByNumberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_compilers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_compilersI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_lll", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_lllI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_solidity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_solidityI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_serpent", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_serpentI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_newFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_newFilterString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_newFilterStringI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_uninstallFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_uninstallFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_changed", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_changedI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_filterLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_filterLogsI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_logs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_logsI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getBlockByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_getBlockByHashI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getBlockByNumber", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_BOOLEAN, NULL), &AbstractWebThreeStubServer::eth_getBlockByNumberI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getTransactionByHash", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getTransactionByHashI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getTransactionByBlockHashAndIndex", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getTransactionByBlockHashAndIndexI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getTransactionByBlockNumberAndIndex", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getTransactionByBlockNumberAndIndexI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getUncleByBlockHashAndIndex", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getUncleByBlockHashAndIndexI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getUncleByBlockNumberAndIndex", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getUncleByBlockNumberAndIndexI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getCompilers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_getCompilersI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_compileLLL", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_compileLLLI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_compileSerpent", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_compileSerpentI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_compileSolidity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_compileSolidityI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_newFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_newBlockFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_newBlockFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_uninstallFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_uninstallFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getFilterChanges", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getFilterChangesI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getFilterLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_getFilterLogsI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_getLogsI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_getWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_getWorkI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_register", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_registerI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_unregister", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_unregisterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_queuedTransactions", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_queuedTransactionsI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_register", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_registerI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_unregister", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_unregisterI);
this->bindAndAddMethod(jsonrpc::Procedure("eth_fetchQueuedTransactions", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_fetchQueuedTransactionsI);
this->bindAndAddMethod(jsonrpc::Procedure("db_put", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING,"param3",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_putI);
this->bindAndAddMethod(jsonrpc::Procedure("db_get", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_getI);
this->bindAndAddMethod(jsonrpc::Procedure("db_putString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING,"param3",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_putStringI);
this->bindAndAddMethod(jsonrpc::Procedure("db_getString", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::db_getStringI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_post", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::shh_postI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_newIdentity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_newIdentityI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_haveIdentity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_haveIdentityI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_hasIdentity", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_hasIdentityI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_newGroup", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_newGroupI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_addToGroup", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_addToGroupI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::shh_newFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_uninstallFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::shh_uninstallFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_changed", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::shh_changedI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_getMessages", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::shh_getMessagesI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_newFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_STRING, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::shh_newFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_uninstallFilter", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_uninstallFilterI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_getFilterChanges", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_getFilterChangesI);
this->bindAndAddMethod(jsonrpc::Procedure("shh_getMessages", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::shh_getMessagesI);
}
inline virtual void web3_sha3I(const Json::Value &request, Json::Value &response)
{
response = this->web3_sha3(request[0u].asString());
}
inline virtual void eth_coinbaseI(const Json::Value &request, Json::Value &response)
inline virtual void net_peerCountI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_coinbase();
}
inline virtual void eth_setCoinbaseI(const Json::Value &request, Json::Value &response)
{
response = this->eth_setCoinbase(request[0u].asString());
response = this->net_peerCount();
}
inline virtual void eth_listeningI(const Json::Value &request, Json::Value &response)
inline virtual void net_listeningI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_listening();
response = this->net_listening();
}
inline virtual void eth_setListeningI(const Json::Value &request, Json::Value &response)
inline virtual void eth_coinbaseI(const Json::Value &request, Json::Value &response)
{
response = this->eth_setListening(request[0u].asBool());
(void)request;
response = this->eth_coinbase();
}
inline virtual void eth_miningI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_mining();
}
inline virtual void eth_setMiningI(const Json::Value &request, Json::Value &response)
{
response = this->eth_setMining(request[0u].asBool());
}
inline virtual void eth_gasPriceI(const Json::Value &request, Json::Value &response)
{
(void)request;
@ -114,138 +101,128 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
(void)request;
response = this->eth_accounts();
}
inline virtual void eth_peerCountI(const Json::Value &request, Json::Value &response)
inline virtual void eth_blockNumberI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_peerCount();
response = this->eth_blockNumber();
}
inline virtual void eth_defaultBlockI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getBalanceI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_defaultBlock();
response = this->eth_getBalance(request[0u].asString(), request[1u].asString());
}
inline virtual void eth_setDefaultBlockI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getStorageI(const Json::Value &request, Json::Value &response)
{
response = this->eth_setDefaultBlock(request[0u].asInt());
response = this->eth_getStorage(request[0u].asString(), request[1u].asString());
}
inline virtual void eth_numberI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getStorageAtI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_number();
response = this->eth_getStorageAt(request[0u].asString(), request[1u].asString(), request[2u].asString());
}
inline virtual void eth_balanceAtI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getTransactionCountI(const Json::Value &request, Json::Value &response)
{
response = this->eth_balanceAt(request[0u].asString());
response = this->eth_getTransactionCount(request[0u].asString(), request[1u].asString());
}
inline virtual void eth_stateAtI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getBlockTransactionCountByHashI(const Json::Value &request, Json::Value &response)
{
response = this->eth_stateAt(request[0u].asString(), request[1u].asString());
response = this->eth_getBlockTransactionCountByHash(request[0u].asString());
}
inline virtual void eth_storageAtI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getBlockTransactionCountByNumberI(const Json::Value &request, Json::Value &response)
{
response = this->eth_storageAt(request[0u].asString());
response = this->eth_getBlockTransactionCountByNumber(request[0u].asString());
}
inline virtual void eth_countAtI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getUncleCountByBlockHashI(const Json::Value &request, Json::Value &response)
{
response = this->eth_countAt(request[0u].asString());
response = this->eth_getUncleCountByBlockHash(request[0u].asString());
}
inline virtual void eth_transactionCountByHashI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getUncleCountByBlockNumberI(const Json::Value &request, Json::Value &response)
{
response = this->eth_transactionCountByHash(request[0u].asString());
response = this->eth_getUncleCountByBlockNumber(request[0u].asString());
}
inline virtual void eth_transactionCountByNumberI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getDataI(const Json::Value &request, Json::Value &response)
{
response = this->eth_transactionCountByNumber(request[0u].asInt());
response = this->eth_getData(request[0u].asString(), request[1u].asString());
}
inline virtual void eth_uncleCountByHashI(const Json::Value &request, Json::Value &response)
inline virtual void eth_sendTransactionI(const Json::Value &request, Json::Value &response)
{
response = this->eth_uncleCountByHash(request[0u].asString());
}
inline virtual void eth_uncleCountByNumberI(const Json::Value &request, Json::Value &response)
{
response = this->eth_uncleCountByNumber(request[0u].asInt());
}
inline virtual void eth_codeAtI(const Json::Value &request, Json::Value &response)
{
response = this->eth_codeAt(request[0u].asString());
}
inline virtual void eth_transactI(const Json::Value &request, Json::Value &response)
{
response = this->eth_transact(request[0u]);
response = this->eth_sendTransaction(request[0u]);
}
inline virtual void eth_callI(const Json::Value &request, Json::Value &response)
{
response = this->eth_call(request[0u]);
response = this->eth_call(request[0u], request[1u].asString());
}
inline virtual void eth_flushI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_flush();
}
inline virtual void eth_blockByHashI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getBlockByHashI(const Json::Value &request, Json::Value &response)
{
response = this->eth_blockByHash(request[0u].asString());
response = this->eth_getBlockByHash(request[0u].asString(), request[1u].asBool());
}
inline virtual void eth_blockByNumberI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getBlockByNumberI(const Json::Value &request, Json::Value &response)
{
response = this->eth_blockByNumber(request[0u].asInt());
response = this->eth_getBlockByNumber(request[0u].asString(), request[1u].asBool());
}
inline virtual void eth_transactionByHashI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getTransactionByHashI(const Json::Value &request, Json::Value &response)
{
response = this->eth_transactionByHash(request[0u].asString(), request[1u].asInt());
response = this->eth_getTransactionByHash(request[0u].asString());
}
inline virtual void eth_transactionByNumberI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getTransactionByBlockHashAndIndexI(const Json::Value &request, Json::Value &response)
{
response = this->eth_transactionByNumber(request[0u].asInt(), request[1u].asInt());
response = this->eth_getTransactionByBlockHashAndIndex(request[0u].asString(), request[1u].asString());
}
inline virtual void eth_uncleByHashI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getTransactionByBlockNumberAndIndexI(const Json::Value &request, Json::Value &response)
{
response = this->eth_uncleByHash(request[0u].asString(), request[1u].asInt());
response = this->eth_getTransactionByBlockNumberAndIndex(request[0u].asString(), request[1u].asString());
}
inline virtual void eth_uncleByNumberI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getUncleByBlockHashAndIndexI(const Json::Value &request, Json::Value &response)
{
response = this->eth_uncleByNumber(request[0u].asInt(), request[1u].asInt());
response = this->eth_getUncleByBlockHashAndIndex(request[0u].asString(), request[1u].asString());
}
inline virtual void eth_compilersI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getUncleByBlockNumberAndIndexI(const Json::Value &request, Json::Value &response)
{
response = this->eth_getUncleByBlockNumberAndIndex(request[0u].asString(), request[1u].asString());
}
inline virtual void eth_getCompilersI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->eth_compilers();
response = this->eth_getCompilers();
}
inline virtual void eth_lllI(const Json::Value &request, Json::Value &response)
inline virtual void eth_compileLLLI(const Json::Value &request, Json::Value &response)
{
response = this->eth_lll(request[0u].asString());
response = this->eth_compileLLL(request[0u].asString());
}
inline virtual void eth_solidityI(const Json::Value &request, Json::Value &response)
inline virtual void eth_compileSerpentI(const Json::Value &request, Json::Value &response)
{
response = this->eth_solidity(request[0u].asString());
response = this->eth_compileSerpent(request[0u].asString());
}
inline virtual void eth_serpentI(const Json::Value &request, Json::Value &response)
inline virtual void eth_compileSolidityI(const Json::Value &request, Json::Value &response)
{
response = this->eth_serpent(request[0u].asString());
response = this->eth_compileSolidity(request[0u].asString());
}
inline virtual void eth_newFilterI(const Json::Value &request, Json::Value &response)
{
response = this->eth_newFilter(request[0u]);
}
inline virtual void eth_newFilterStringI(const Json::Value &request, Json::Value &response)
inline virtual void eth_newBlockFilterI(const Json::Value &request, Json::Value &response)
{
response = this->eth_newFilterString(request[0u].asString());
response = this->eth_newBlockFilter(request[0u].asString());
}
inline virtual void eth_uninstallFilterI(const Json::Value &request, Json::Value &response)
{
response = this->eth_uninstallFilter(request[0u].asInt());
response = this->eth_uninstallFilter(request[0u].asString());
}
inline virtual void eth_changedI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getFilterChangesI(const Json::Value &request, Json::Value &response)
{
response = this->eth_changed(request[0u].asInt());
response = this->eth_getFilterChanges(request[0u].asString());
}
inline virtual void eth_filterLogsI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getFilterLogsI(const Json::Value &request, Json::Value &response)
{
response = this->eth_filterLogs(request[0u].asInt());
response = this->eth_getFilterLogs(request[0u].asString());
}
inline virtual void eth_logsI(const Json::Value &request, Json::Value &response)
inline virtual void eth_getLogsI(const Json::Value &request, Json::Value &response)
{
response = this->eth_logs(request[0u]);
response = this->eth_getLogs(request[0u]);
}
inline virtual void eth_getWorkI(const Json::Value &request, Json::Value &response)
{
@ -262,11 +239,11 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
}
inline virtual void eth_unregisterI(const Json::Value &request, Json::Value &response)
{
response = this->eth_unregister(request[0u].asInt());
response = this->eth_unregister(request[0u].asString());
}
inline virtual void eth_queuedTransactionsI(const Json::Value &request, Json::Value &response)
inline virtual void eth_fetchQueuedTransactionsI(const Json::Value &request, Json::Value &response)
{
response = this->eth_queuedTransactions(request[0u].asInt());
response = this->eth_fetchQueuedTransactions(request[0u].asString());
}
inline virtual void db_putI(const Json::Value &request, Json::Value &response)
{
@ -276,14 +253,6 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
{
response = this->db_get(request[0u].asString(), request[1u].asString());
}
inline virtual void db_putStringI(const Json::Value &request, Json::Value &response)
{
response = this->db_putString(request[0u].asString(), request[1u].asString(), request[2u].asString());
}
inline virtual void db_getStringI(const Json::Value &request, Json::Value &response)
{
response = this->db_getString(request[0u].asString(), request[1u].asString());
}
inline virtual void shh_postI(const Json::Value &request, Json::Value &response)
{
response = this->shh_post(request[0u]);
@ -293,9 +262,9 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
(void)request;
response = this->shh_newIdentity();
}
inline virtual void shh_haveIdentityI(const Json::Value &request, Json::Value &response)
inline virtual void shh_hasIdentityI(const Json::Value &request, Json::Value &response)
{
response = this->shh_haveIdentity(request[0u].asString());
response = this->shh_hasIdentity(request[0u].asString());
}
inline virtual void shh_newGroupI(const Json::Value &request, Json::Value &response)
{
@ -311,75 +280,69 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer<AbstractWebThr
}
inline virtual void shh_uninstallFilterI(const Json::Value &request, Json::Value &response)
{
response = this->shh_uninstallFilter(request[0u].asInt());
response = this->shh_uninstallFilter(request[0u].asString());
}
inline virtual void shh_changedI(const Json::Value &request, Json::Value &response)
inline virtual void shh_getFilterChangesI(const Json::Value &request, Json::Value &response)
{
response = this->shh_changed(request[0u].asInt());
response = this->shh_getFilterChanges(request[0u].asString());
}
inline virtual void shh_getMessagesI(const Json::Value &request, Json::Value &response)
{
response = this->shh_getMessages(request[0u].asInt());
response = this->shh_getMessages(request[0u].asString());
}
virtual std::string web3_sha3(const std::string& param1) = 0;
virtual std::string net_peerCount() = 0;
virtual bool net_listening() = 0;
virtual std::string eth_coinbase() = 0;
virtual bool eth_setCoinbase(const std::string& param1) = 0;
virtual bool eth_listening() = 0;
virtual bool eth_setListening(bool param1) = 0;
virtual bool eth_mining() = 0;
virtual bool eth_setMining(bool param1) = 0;
virtual std::string eth_gasPrice() = 0;
virtual Json::Value eth_accounts() = 0;
virtual int eth_peerCount() = 0;
virtual int eth_defaultBlock() = 0;
virtual bool eth_setDefaultBlock(int param1) = 0;
virtual int eth_number() = 0;
virtual std::string eth_balanceAt(const std::string& param1) = 0;
virtual std::string eth_stateAt(const std::string& param1, const std::string& param2) = 0;
virtual Json::Value eth_storageAt(const std::string& param1) = 0;
virtual double eth_countAt(const std::string& param1) = 0;
virtual double eth_transactionCountByHash(const std::string& param1) = 0;
virtual double eth_transactionCountByNumber(int param1) = 0;
virtual double eth_uncleCountByHash(const std::string& param1) = 0;
virtual double eth_uncleCountByNumber(int param1) = 0;
virtual std::string eth_codeAt(const std::string& param1) = 0;
virtual std::string eth_transact(const Json::Value& param1) = 0;
virtual std::string eth_call(const Json::Value& param1) = 0;
virtual std::string eth_blockNumber() = 0;
virtual std::string eth_getBalance(const std::string& param1, const std::string& param2) = 0;
virtual Json::Value eth_getStorage(const std::string& param1, const std::string& param2) = 0;
virtual std::string eth_getStorageAt(const std::string& param1, const std::string& param2, const std::string& param3) = 0;
virtual std::string eth_getTransactionCount(const std::string& param1, const std::string& param2) = 0;
virtual std::string eth_getBlockTransactionCountByHash(const std::string& param1) = 0;
virtual std::string eth_getBlockTransactionCountByNumber(const std::string& param1) = 0;
virtual std::string eth_getUncleCountByBlockHash(const std::string& param1) = 0;
virtual std::string eth_getUncleCountByBlockNumber(const std::string& param1) = 0;
virtual std::string eth_getData(const std::string& param1, const std::string& param2) = 0;
virtual std::string eth_sendTransaction(const Json::Value& param1) = 0;
virtual std::string eth_call(const Json::Value& param1, const std::string& param2) = 0;
virtual bool eth_flush() = 0;
virtual Json::Value eth_blockByHash(const std::string& param1) = 0;
virtual Json::Value eth_blockByNumber(int param1) = 0;
virtual Json::Value eth_transactionByHash(const std::string& param1, int param2) = 0;
virtual Json::Value eth_transactionByNumber(int param1, int param2) = 0;
virtual Json::Value eth_uncleByHash(const std::string& param1, int param2) = 0;
virtual Json::Value eth_uncleByNumber(int param1, int param2) = 0;
virtual Json::Value eth_compilers() = 0;
virtual std::string eth_lll(const std::string& param1) = 0;
virtual std::string eth_solidity(const std::string& param1) = 0;
virtual std::string eth_serpent(const std::string& param1) = 0;
virtual int eth_newFilter(const Json::Value& param1) = 0;
virtual int eth_newFilterString(const std::string& param1) = 0;
virtual bool eth_uninstallFilter(int param1) = 0;
virtual Json::Value eth_changed(int param1) = 0;
virtual Json::Value eth_filterLogs(int param1) = 0;
virtual Json::Value eth_logs(const Json::Value& param1) = 0;
virtual Json::Value eth_getBlockByHash(const std::string& param1, bool param2) = 0;
virtual Json::Value eth_getBlockByNumber(const std::string& param1, bool param2) = 0;
virtual Json::Value eth_getTransactionByHash(const std::string& param1) = 0;
virtual Json::Value eth_getTransactionByBlockHashAndIndex(const std::string& param1, const std::string& param2) = 0;
virtual Json::Value eth_getTransactionByBlockNumberAndIndex(const std::string& param1, const std::string& param2) = 0;
virtual Json::Value eth_getUncleByBlockHashAndIndex(const std::string& param1, const std::string& param2) = 0;
virtual Json::Value eth_getUncleByBlockNumberAndIndex(const std::string& param1, const std::string& param2) = 0;
virtual Json::Value eth_getCompilers() = 0;
virtual std::string eth_compileLLL(const std::string& param1) = 0;
virtual std::string eth_compileSerpent(const std::string& param1) = 0;
virtual std::string eth_compileSolidity(const std::string& param1) = 0;
virtual std::string eth_newFilter(const Json::Value& param1) = 0;
virtual std::string eth_newBlockFilter(const std::string& param1) = 0;
virtual bool eth_uninstallFilter(const std::string& param1) = 0;
virtual Json::Value eth_getFilterChanges(const std::string& param1) = 0;
virtual Json::Value eth_getFilterLogs(const std::string& param1) = 0;
virtual Json::Value eth_getLogs(const Json::Value& param1) = 0;
virtual Json::Value eth_getWork() = 0;
virtual bool eth_submitWork(const std::string& param1, const std::string& param2) = 0;
virtual int eth_register(const std::string& param1) = 0;
virtual bool eth_unregister(int param1) = 0;
virtual Json::Value eth_queuedTransactions(int param1) = 0;
virtual std::string eth_register(const std::string& param1) = 0;
virtual bool eth_unregister(const std::string& param1) = 0;
virtual Json::Value eth_fetchQueuedTransactions(const std::string& param1) = 0;
virtual bool db_put(const std::string& param1, const std::string& param2, const std::string& param3) = 0;
virtual std::string db_get(const std::string& param1, const std::string& param2) = 0;
virtual bool db_putString(const std::string& param1, const std::string& param2, const std::string& param3) = 0;
virtual std::string db_getString(const std::string& param1, const std::string& param2) = 0;
virtual bool shh_post(const Json::Value& param1) = 0;
virtual std::string shh_newIdentity() = 0;
virtual bool shh_haveIdentity(const std::string& param1) = 0;
virtual bool shh_hasIdentity(const std::string& param1) = 0;
virtual std::string shh_newGroup(const std::string& param1, const std::string& param2) = 0;
virtual std::string shh_addToGroup(const std::string& param1, const std::string& param2) = 0;
virtual int shh_newFilter(const Json::Value& param1) = 0;
virtual bool shh_uninstallFilter(int param1) = 0;
virtual Json::Value shh_changed(int param1) = 0;
virtual Json::Value shh_getMessages(int param1) = 0;
virtual std::string shh_newFilter(const Json::Value& param1) = 0;
virtual bool shh_uninstallFilter(const std::string& param1) = 0;
virtual Json::Value shh_getFilterChanges(const std::string& param1) = 0;
virtual Json::Value shh_getMessages(const std::string& param1) = 0;
};
#endif //JSONRPC_CPP_STUB_ABSTRACTWEBTHREESTUBSERVER_H_

93
libweb3jsonrpc/spec.json

@ -1,73 +1,60 @@
[
{ "name": "web3_sha3", "params": [""], "order": [], "returns" : "" },
{ "name": "net_peerCount", "params": [], "order": [], "returns" : "" },
{ "name": "net_listening", "params": [], "order": [], "returns" : false },
{ "name": "eth_coinbase", "params": [], "order": [], "returns" : "" },
{ "name": "eth_setCoinbase", "params": [""], "order": [], "returns" : true },
{ "name": "eth_listening", "params": [], "order": [], "returns" : false },
{ "name": "eth_setListening", "params": [false], "order" : [], "returns" : true },
{ "name": "eth_mining", "params": [], "order": [], "returns" : false },
{ "name": "eth_setMining", "params": [false], "order" : [], "returns" : true },
{ "name": "eth_gasPrice", "params": [], "order": [], "returns" : "" },
{ "name": "eth_accounts", "params": [], "order": [], "returns" : [] },
{ "name": "eth_peerCount", "params": [], "order": [], "returns" : 0 },
{ "name": "eth_defaultBlock", "params": [], "order": [], "returns" : 0},
{ "name": "eth_setDefaultBlock", "params": [0], "order": [], "returns" : true},
{ "name": "eth_number", "params": [], "order": [], "returns" : 0},
{ "name": "eth_balanceAt", "params": [""], "order": [], "returns" : ""},
{ "name": "eth_stateAt", "params": ["", ""], "order": [], "returns": ""},
{ "name": "eth_storageAt", "params": [""], "order": [], "returns": {}},
{ "name": "eth_countAt", "params": [""], "order": [], "returns" : 0.0},
{ "name": "eth_transactionCountByHash", "params": [""], "order": [], "returns" : 0.0},
{ "name": "eth_transactionCountByNumber", "params": [0], "order": [], "returns" : 0.0},
{ "name": "eth_uncleCountByHash", "params": [""], "order": [], "returns" : 0.0},
{ "name": "eth_uncleCountByNumber", "params": [0], "order": [], "returns" : 0.0},
{ "name": "eth_codeAt", "params": [""], "order": [], "returns": ""},
{ "name": "eth_transact", "params": [{}], "order": [], "returns": ""},
{ "name": "eth_call", "params": [{}], "order": [], "returns": ""},
{ "name": "eth_blockNumber", "params": [], "order": [], "returns" : ""},
{ "name": "eth_getBalance", "params": ["", ""], "order": [], "returns" : ""},
{ "name": "eth_getStorage", "params": ["", ""], "order": [], "returns": {}},
{ "name": "eth_getStorageAt", "params": ["", "", ""], "order": [], "returns": ""},
{ "name": "eth_getTransactionCount", "params": ["", ""], "order": [], "returns" : ""},
{ "name": "eth_getBlockTransactionCountByHash", "params": [""], "order": [], "returns" : ""},
{ "name": "eth_getBlockTransactionCountByNumber", "params": [""], "order": [], "returns" : ""},
{ "name": "eth_getUncleCountByBlockHash", "params": [""], "order": [], "returns" : ""},
{ "name": "eth_getUncleCountByBlockNumber", "params": [""], "order": [], "returns" : ""},
{ "name": "eth_getData", "params": ["", ""], "order": [], "returns": ""},
{ "name": "eth_sendTransaction", "params": [{}], "order": [], "returns": ""},
{ "name": "eth_call", "params": [{}, ""], "order": [], "returns": ""},
{ "name": "eth_flush", "params": [], "order": [], "returns" : true},
{ "name": "eth_blockByHash", "params": [""],"order": [], "returns": {}},
{ "name": "eth_blockByNumber", "params": [0],"order": [], "returns": {}},
{ "name": "eth_transactionByHash", "params": ["", 0], "order": [], "returns": {}},
{ "name": "eth_transactionByNumber", "params": [0, 0], "order": [], "returns": {}},
{ "name": "eth_uncleByHash", "params": ["", 0], "order": [], "returns": {}},
{ "name": "eth_uncleByNumber", "params": [0, 0], "order": [], "returns": {}},
{ "name": "eth_compilers", "params": [], "order": [], "returns": []},
{ "name": "eth_lll", "params": [""], "order": [], "returns": ""},
{ "name": "eth_solidity", "params": [""], "order": [], "returns": ""},
{ "name": "eth_serpent", "params": [""], "order": [], "returns": ""},
{ "name": "eth_newFilter", "params": [{}], "order": [], "returns": 0},
{ "name": "eth_newFilterString", "params": [""], "order": [], "returns": 0},
{ "name": "eth_uninstallFilter", "params": [0], "order": [], "returns": true},
{ "name": "eth_changed", "params": [0], "order": [], "returns": []},
{ "name": "eth_filterLogs", "params": [0], "order": [], "returns": []},
{ "name": "eth_logs", "params": [{}], "order": [], "returns": []},
{ "name": "eth_getBlockByHash", "params": ["", false],"order": [], "returns": {}},
{ "name": "eth_getBlockByNumber", "params": ["", false],"order": [], "returns": {}},
{ "name": "eth_getTransactionByHash", "params": [""], "order": [], "returns": {}},
{ "name": "eth_getTransactionByBlockHashAndIndex", "params": ["", ""], "order": [], "returns": {}},
{ "name": "eth_getTransactionByBlockNumberAndIndex", "params": ["", ""], "order": [], "returns": {}},
{ "name": "eth_getUncleByBlockHashAndIndex", "params": ["", ""], "order": [], "returns": {}},
{ "name": "eth_getUncleByBlockNumberAndIndex", "params": ["", ""], "order": [], "returns": {}},
{ "name": "eth_getCompilers", "params": [], "order": [], "returns": []},
{ "name": "eth_compileLLL", "params": [""], "order": [], "returns": ""},
{ "name": "eth_compileSerpent", "params": [""], "order": [], "returns": ""},
{ "name": "eth_compileSolidity", "params": [""], "order": [], "returns": ""},
{ "name": "eth_newFilter", "params": [{}], "order": [], "returns": ""},
{ "name": "eth_newBlockFilter", "params": [""], "order": [], "returns": ""},
{ "name": "eth_uninstallFilter", "params": [""], "order": [], "returns": true},
{ "name": "eth_getFilterChanges", "params": [""], "order": [], "returns": []},
{ "name": "eth_getFilterLogs", "params": [""], "order": [], "returns": []},
{ "name": "eth_getLogs", "params": [{}], "order": [], "returns": []},
{ "name": "eth_getWork", "params": [], "order": [], "returns": []},
{ "name": "eth_submitWork", "params": ["", ""], "order": [], "returns": true},
{ "name": "eth_register", "params": [""], "order": [], "returns": 0},
{ "name": "eth_unregister", "params": [0], "order": [], "returns": true},
{ "name": "eth_queuedTransactions", "params": [0], "order": [], "returns": []},
{ "name": "eth_register", "params": [""], "order": [], "returns": ""},
{ "name": "eth_unregister", "params": [""], "order": [], "returns": true},
{ "name": "eth_fetchQueuedTransactions", "params": [""], "order": [], "returns": []},
{ "name": "db_put", "params": ["", "", ""], "order": [], "returns": true},
{ "name": "db_get", "params": ["", ""], "order": [], "returns": ""},
{ "name": "db_putString", "params": ["", "", ""], "order": [], "returns": true},
{ "name": "db_getString", "params": ["", ""], "order": [], "returns": ""},
{ "name": "shh_post", "params": [{}], "order": [], "returns": true},
{ "name": "shh_newIdentity", "params": [], "order": [], "returns": ""},
{ "name": "shh_haveIdentity", "params": [""], "order": [], "returns": false},
{ "name": "shh_hasIdentity", "params": [""], "order": [], "returns": false},
{ "name": "shh_newGroup", "params": ["", ""], "order": [], "returns": ""},
{ "name": "shh_addToGroup", "params": ["", ""], "order": [], "returns": ""},
{ "name": "shh_newFilter", "params": [{}], "order": [], "returns": 0},
{ "name": "shh_uninstallFilter", "params": [0], "order": [], "returns": true},
{ "name": "shh_changed", "params": [0], "order": [], "returns": []},
{ "name": "shh_getMessages", "params": [0], "order": [], "returns": []}
{ "name": "shh_newFilter", "params": [{}], "order": [], "returns": ""},
{ "name": "shh_uninstallFilter", "params": [""], "order": [], "returns": true},
{ "name": "shh_getFilterChanges", "params": [""], "order": [], "returns": []},
{ "name": "shh_getMessages", "params": [""], "order": [], "returns": []}
]

30
mix/MixClient.cpp

@ -274,13 +274,13 @@ void MixClient::flushTransactions()
{
}
bytes MixClient::call(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice)
bytes MixClient::call(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, int _blockNumber)
{
u256 n;
State temp;
{
ReadGuard lr(x_state);
temp = m_state;
temp = asOf(_blockNumber);
n = temp.transactionsFrom(toAddress(_secret));
}
Transaction t(_value, _gasPrice, _gas, _dest, _data, n, _secret);
@ -388,13 +388,13 @@ unsigned MixClient::installWatch(eth::LogFilter const& _f)
return installWatch(h);
}
void MixClient::uninstallWatch(unsigned _i)
bool MixClient::uninstallWatch(unsigned _i)
{
Guard l(m_filterLock);
auto it = m_watches.find(_i);
if (it == m_watches.end())
return;
return false;
auto id = it->second.id;
m_watches.erase(it);
@ -402,6 +402,8 @@ void MixClient::uninstallWatch(unsigned _i)
if (fit != m_filters.end())
if (!--fit->second.refCount)
m_filters.erase(fit);
return true;
}
void MixClient::noteChanged(h256Set const& _filters)
@ -456,6 +458,11 @@ eth::BlockDetails MixClient::blockDetails(h256 _hash) const
return bc().details(_hash);
}
Transaction MixClient::transaction(h256 _transactionHash) const
{
return Transaction(bc().transaction(_transactionHash), CheckSignature::Range);
}
eth::Transaction MixClient::transaction(h256 _blockHash, unsigned _i) const
{
auto bl = bc().block(_blockHash);
@ -490,6 +497,21 @@ unsigned MixClient::uncleCount(h256 _blockHash) const
return b[2].itemCount();
}
Transactions MixClient::transactions(h256 _blockHash) const
{
auto bl = bc().block(_blockHash);
RLP b(bl);
Transactions res;
for (unsigned i = 0; i < b[1].itemCount(); i++)
res.emplace_back(b[1][i].data(), CheckSignature::Range);
return res;
}
TransactionHashes MixClient::transactionHashes(h256 _blockHash) const
{
return bc().transactionHashes(_blockHash);
}
unsigned MixClient::number() const
{
return bc().number();

7
mix/MixClient.h

@ -52,7 +52,7 @@ public:
Address transact(Secret _secret, u256 _endowment, bytes const& _init, u256 _gas, u256 _gasPrice) override;
void inject(bytesConstRef _rlp) override;
void flushTransactions() override;
bytes call(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice) override;
bytes call(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, int _blockNumber) override;
u256 balanceAt(Address _a, int _block) const override;
u256 countAt(Address _a, int _block) const override;
u256 stateAt(Address _a, u256 _l, int _block) const override;
@ -62,16 +62,19 @@ public:
eth::LocalisedLogEntries logs(eth::LogFilter const& _filter) const override;
unsigned installWatch(eth::LogFilter const& _filter) override;
unsigned installWatch(h256 _filterId) override;
void uninstallWatch(unsigned _watchId) override;
bool uninstallWatch(unsigned _watchId) override;
eth::LocalisedLogEntries peekWatch(unsigned _watchId) const override;
eth::LocalisedLogEntries checkWatch(unsigned _watchId) override;
h256 hashFromNumber(unsigned _number) const override;
eth::BlockInfo blockInfo(h256 _hash) const override;
eth::BlockDetails blockDetails(h256 _hash) const override;
eth::Transaction transaction(h256 _transactionHash) const override;
eth::Transaction transaction(h256 _blockHash, unsigned _i) const override;
eth::BlockInfo uncle(h256 _blockHash, unsigned _i) const override;
unsigned transactionCount(h256 _blockHash) const override;
unsigned uncleCount(h256 _blockHash) const override;
eth::Transactions transactions(h256 _blockHash) const override;
eth::TransactionHashes transactionHashes(h256 _blockHash) const override;
unsigned number() const override;
eth::Transactions pending() const override;
eth::StateDiff diff(unsigned _txi, h256 _block) const override;

12
mix/Web3Server.cpp

@ -55,21 +55,21 @@ void Web3Server::put(std::string const& _name, std::string const& _key, std::str
m_db[k] = _value;
}
Json::Value Web3Server::eth_changed(int _id)
Json::Value Web3Server::eth_getFilterChanges(std::string const& _filterId)
{
return WebThreeStubServerBase::eth_changed(_id);
return WebThreeStubServerBase::eth_getFilterChanges(_filterId);
}
std::string Web3Server::eth_transact(Json::Value const& _json)
std::string Web3Server::eth_sendTransaction(Json::Value const& _json)
{
std::string ret = WebThreeStubServerBase::eth_transact(_json);
std::string ret = WebThreeStubServerBase::eth_sendTransaction(_json);
emit newTransaction();
return ret;
}
std::string Web3Server::eth_call(Json::Value const& _json)
std::string Web3Server::eth_call(Json::Value const& _json, std::string const& _blockNumber)
{
std::string ret = WebThreeStubServerBase::eth_call(_json);
std::string ret = WebThreeStubServerBase::eth_call(_json, _blockNumber);
emit newTransaction();
return ret;
}

6
mix/Web3Server.h

@ -44,9 +44,9 @@ signals:
void newTransaction();
protected:
virtual Json::Value eth_changed(int _id) override;
virtual std::string eth_transact(Json::Value const& _json) override;
virtual std::string eth_call(Json::Value const& _json) override;
virtual Json::Value eth_getFilterChanges(std::string const& _filterId) override;
virtual std::string eth_sendTransaction(Json::Value const& _json) override;
virtual std::string eth_call(Json::Value const& _json, std::string const& _blockNumber) override;
private:
dev::eth::Interface* client() override { return m_client; }

80
test/TestHelper.cpp

@ -439,8 +439,6 @@ void userDefinedTest(string testTypeFlag, std::function<void(json_spirit::mValue
}
g_logVerbosity = currentVerbosity;
}
else
continue;
}
}
@ -449,32 +447,27 @@ void executeTests(const string& _name, const string& _testPathAppendix, std::fun
string testPath = getTestPath();
testPath += _testPathAppendix;
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
if (Options::get().fillTests)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--filltests")
try
{
try
{
cnote << "Populating tests...";
json_spirit::mValue v;
boost::filesystem::path p(__FILE__);
boost::filesystem::path dir = p.parent_path();
string s = asString(dev::contents(dir.string() + "/" + _name + "Filler.json"));
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + dir.string() + "/" + _name + "Filler.json is empty.");
json_spirit::read_string(s, v);
doTests(v, true);
writeFile(testPath + "/" + _name + ".json", asBytes(json_spirit::write_string(v, true)));
}
catch (Exception const& _e)
{
BOOST_ERROR("Failed filling test with Exception: " << diagnostic_information(_e));
}
catch (std::exception const& _e)
{
BOOST_ERROR("Failed filling test with Exception: " << _e.what());
}
break;
cnote << "Populating tests...";
json_spirit::mValue v;
boost::filesystem::path p(__FILE__);
boost::filesystem::path dir = p.parent_path();
string s = asString(dev::contents(dir.string() + "/" + _name + "Filler.json"));
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + dir.string() + "/" + _name + "Filler.json is empty.");
json_spirit::read_string(s, v);
doTests(v, true);
writeFile(testPath + "/" + _name + ".json", asBytes(json_spirit::write_string(v, true)));
}
catch (Exception const& _e)
{
BOOST_ERROR("Failed filling test with Exception: " << diagnostic_information(_e));
}
catch (std::exception const& _e)
{
BOOST_ERROR("Failed filling test with Exception: " << _e.what());
}
}
@ -541,21 +534,48 @@ RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj)
return rlpStream;
}
void processCommandLineOptions()
Options::Options()
{
auto argc = boost::unit_test::framework::master_test_suite().argc;
auto argv = boost::unit_test::framework::master_test_suite().argv;
for (auto i = 0; i < argc; ++i)
for (auto i = 0; i < argc; ++i)
{
if (std::string(argv[i]) == "--jit")
auto arg = std::string{argv[i]};
if (arg == "--jit")
{
jit = true;
eth::VMFactory::setKind(eth::VMKind::JIT);
break;
}
else if (arg == "--vmtrace")
vmtrace = true;
else if (arg == "--performance")
performance = true;
else if (arg == "--quadratic")
quadratic = true;
else if (arg == "--memory")
memory = true;
else if (arg == "--inputlimits")
inputLimits = true;
else if (arg == "--bigdata")
bigData = true;
else if (arg == "--all")
{
performance = true;
quadratic = true;
memory = true;
inputLimits = true;
bigData = true;
}
}
}
Options const& Options::get()
{
static Options instance;
return instance;
}
LastHashes lastHashes(u256 _currentBlockNumber)
{
LastHashes ret;

27
test/TestHelper.h

@ -141,7 +141,6 @@ void executeTests(const std::string& _name, const std::string& _testPathAppendix
std::string getTestPath();
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests);
RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj);
void processCommandLineOptions();
eth::LastHashes lastHashes(u256 _currentBlockNumber);
json_spirit::mObject fillJsonWithState(eth::State _state);
@ -158,5 +157,31 @@ void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
BOOST_CHECK(_expectedAddrs == _resultAddrs);
}
class Options
{
public:
bool jit = false; ///< Use JIT
bool vmtrace = false; ///< Create EVM execution tracer // TODO: Link with log verbosity?
bool showTimes = false; ///< Print test groups execution times
bool fillTests = false; ///< Create JSON test files from execution results
/// Test selection
/// @{
bool performance = false;
bool quadratic = false;
bool memory = false;
bool inputLimits = false;
bool bigData = false;
/// @}
/// Get reference to options
/// The first time used, options are parsed
static Options const& get();
private:
Options();
Options(Options const&) = delete;
};
}
}

60
test/state.cpp

@ -41,7 +41,7 @@ namespace dev { namespace test {
void doStateTests(json_spirit::mValue& v, bool _fillin)
{
processCommandLineOptions();
Options::get(); // process command line options
for (auto& i: v.get_obj())
{
@ -172,48 +172,40 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest)
BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--quadratic" || arg == "--all")
{
auto start = chrono::steady_clock::now();
dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests);
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
}
if (test::Options::get().quadratic)
{
auto start = chrono::steady_clock::now();
dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests);
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
}
BOOST_AUTO_TEST_CASE(stMemoryStressTest)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--memory" || arg == "--all")
{
auto start = chrono::steady_clock::now();
dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests);
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
}
if (test::Options::get().memory)
{
auto start = chrono::steady_clock::now();
dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests);
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
}
BOOST_AUTO_TEST_CASE(stSolidityTest)
{
dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests);
}
BOOST_AUTO_TEST_CASE(stSolidityTest)
{
dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests);
}
BOOST_AUTO_TEST_CASE(stMemoryTest)
{
dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests);
dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests);
}

17
test/transaction.cpp

@ -116,21 +116,16 @@ BOOST_AUTO_TEST_CASE(ttWrongRLPTransaction)
BOOST_AUTO_TEST_CASE(tt10mbDataField)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
if (test::Options::get().bigData)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--bigdata" || arg == "--all")
{
auto start = chrono::steady_clock::now();
auto start = chrono::steady_clock::now();
dev::test::executeTests("tt10mbDataField", "/TransactionTests", dev::test::doTransactionTests);
dev::test::executeTests("tt10mbDataField", "/TransactionTests", dev::test::doTransactionTests);
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
}
BOOST_AUTO_TEST_CASE(ttCreateTest)

69
test/vm.cpp

@ -312,7 +312,7 @@ namespace dev { namespace test {
void doVMTests(json_spirit::mValue& v, bool _fillin)
{
processCommandLineOptions();
Options::get(); // process command line options // TODO: We need to control the main() function
for (auto& i: v.get_obj())
{
@ -344,7 +344,8 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
try
{
auto vm = eth::VMFactory::create(fev.gas);
output = vm->go(fev, fev.simpleTrace()).toBytes();
auto vmtrace = Options::get().vmtrace ? fev.simpleTrace() : OnOpFunc{};
output = vm->go(fev, vmtrace).toBytes();
gas = vm->gas();
}
catch (VMException const&)
@ -364,18 +365,12 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
}
auto endTime = std::chrono::high_resolution_clock::now();
auto argc = boost::unit_test::framework::master_test_suite().argc;
auto argv = boost::unit_test::framework::master_test_suite().argv;
for (auto i = 0; i < argc; ++i)
if (Options::get().showTimes)
{
if (std::string(argv[i]) == "--show-times")
{
auto testDuration = endTime - startTime;
cnote << "Execution time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(testDuration).count()
<< " ms";
break;
}
auto testDuration = endTime - startTime;
cnote << "Execution time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>(testDuration).count()
<< " ms";
}
// delete null entries in storage for the sake of comparison
@ -517,58 +512,42 @@ BOOST_AUTO_TEST_CASE(vmSystemOperationsTest)
BOOST_AUTO_TEST_CASE(vmPerformanceTest)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
if (test::Options::get().performance)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--performance" || arg == "--all")
{
auto start = chrono::steady_clock::now();
auto start = chrono::steady_clock::now();
dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests);
dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests);
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
}
BOOST_AUTO_TEST_CASE(vmInputLimitsTest1)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
if (test::Options::get().inputLimits)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--inputlimits" || arg == "--all")
{
auto start = chrono::steady_clock::now();
auto start = chrono::steady_clock::now();
dev::test::executeTests("vmInputLimits1", "/VMTests", dev::test::doVMTests);
dev::test::executeTests("vmInputLimits1", "/VMTests", dev::test::doVMTests);
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
auto end = chrono::steady_clock::now();
auto duration(chrono::duration_cast<chrono::milliseconds>(end - start));
cnote << "test duration: " << duration.count() << " milliseconds.\n";
}
}
BOOST_AUTO_TEST_CASE(vmInputLimitsTest2)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--inputlimits" || arg == "--all")
dev::test::executeTests("vmInputLimits2", "/VMTests", dev::test::doVMTests);
}
if (test::Options::get().inputLimits)
dev::test::executeTests("vmInputLimits2", "/VMTests", dev::test::doVMTests);
}
BOOST_AUTO_TEST_CASE(vmInputLimitsLightTest)
{
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
{
string arg = boost::unit_test::framework::master_test_suite().argv[i];
if (arg == "--inputlimits" || arg == "--all")
dev::test::executeTests("vmInputLimitsLight", "/VMTests", dev::test::doVMTests);
}
if (test::Options::get().inputLimits)
dev::test::executeTests("vmInputLimitsLight", "/VMTests", dev::test::doVMTests);
}
BOOST_AUTO_TEST_CASE(vmRandom)

283
test/webthreestubclient.h

@ -22,43 +22,33 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_coinbase() throw (jsonrpc::JsonRpcException)
std::string net_peerCount() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_coinbase",p);
Json::Value result = this->CallMethod("net_peerCount",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_setCoinbase(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_setCoinbase",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_listening() throw (jsonrpc::JsonRpcException)
bool net_listening() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_listening",p);
Json::Value result = this->CallMethod("net_listening",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_setListening(bool param1) throw (jsonrpc::JsonRpcException)
std::string eth_coinbase() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_setListening",p);
if (result.isBool())
return result.asBool();
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_coinbase",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
@ -72,16 +62,6 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_setMining(bool param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_setMining",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_gasPrice() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
@ -102,151 +82,127 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
int eth_peerCount() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_peerCount",p);
if (result.isInt())
return result.asInt();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
int eth_defaultBlock() throw (jsonrpc::JsonRpcException)
std::string eth_blockNumber() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_defaultBlock",p);
if (result.isInt())
return result.asInt();
Json::Value result = this->CallMethod("eth_blockNumber",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_setDefaultBlock(int param1) throw (jsonrpc::JsonRpcException)
std::string eth_getBalance(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_setDefaultBlock",p);
if (result.isBool())
return result.asBool();
p.append(param2);
Json::Value result = this->CallMethod("eth_getBalance",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
int eth_number() throw (jsonrpc::JsonRpcException)
Json::Value eth_getStorage(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_number",p);
if (result.isInt())
return result.asInt();
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("eth_getStorage",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_balanceAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_getStorageAt(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_balanceAt",p);
p.append(param2);
p.append(param3);
Json::Value result = this->CallMethod("eth_getStorageAt",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_stateAt(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
std::string eth_getTransactionCount(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("eth_stateAt",p);
Json::Value result = this->CallMethod("eth_getTransactionCount",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_storageAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_storageAt",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
double eth_countAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_getBlockTransactionCountByHash(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_countAt",p);
if (result.isDouble())
return result.asDouble();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
double eth_transactionCountByHash(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_transactionCountByHash",p);
if (result.isDouble())
return result.asDouble();
Json::Value result = this->CallMethod("eth_getBlockTransactionCountByHash",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
double eth_transactionCountByNumber(int param1) throw (jsonrpc::JsonRpcException)
std::string eth_getBlockTransactionCountByNumber(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_transactionCountByNumber",p);
if (result.isDouble())
return result.asDouble();
Json::Value result = this->CallMethod("eth_getBlockTransactionCountByNumber",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
double eth_uncleCountByHash(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_getUncleCountByBlockHash(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_uncleCountByHash",p);
if (result.isDouble())
return result.asDouble();
Json::Value result = this->CallMethod("eth_getUncleCountByBlockHash",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
double eth_uncleCountByNumber(int param1) throw (jsonrpc::JsonRpcException)
std::string eth_getUncleCountByBlockNumber(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_uncleCountByNumber",p);
if (result.isDouble())
return result.asDouble();
Json::Value result = this->CallMethod("eth_getUncleCountByBlockNumber",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_codeAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_getData(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_codeAt",p);
p.append(param2);
Json::Value result = this->CallMethod("eth_getData",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_transact(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
std::string eth_sendTransaction(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_transact",p);
Json::Value result = this->CallMethod("eth_sendTransaction",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_call(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
std::string eth_call(const Json::Value& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("eth_call",p);
if (result.isString())
return result.asString();
@ -263,131 +219,143 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_blockByHash(const std::string& param1) throw (jsonrpc::JsonRpcException)
Json::Value eth_getBlockByHash(const std::string& param1, bool param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_blockByHash",p);
p.append(param2);
Json::Value result = this->CallMethod("eth_getBlockByHash",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_blockByNumber(int param1) throw (jsonrpc::JsonRpcException)
Json::Value eth_getBlockByNumber(const std::string& param1, bool param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_blockByNumber",p);
p.append(param2);
Json::Value result = this->CallMethod("eth_getBlockByNumber",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_transactionByHash(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException)
Json::Value eth_getTransactionByHash(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_getTransactionByHash",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_getTransactionByBlockHashAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("eth_transactionByHash",p);
Json::Value result = this->CallMethod("eth_getTransactionByBlockHashAndIndex",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_transactionByNumber(int param1, int param2) throw (jsonrpc::JsonRpcException)
Json::Value eth_getTransactionByBlockNumberAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("eth_transactionByNumber",p);
Json::Value result = this->CallMethod("eth_getTransactionByBlockNumberAndIndex",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_uncleByHash(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException)
Json::Value eth_getUncleByBlockHashAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("eth_uncleByHash",p);
Json::Value result = this->CallMethod("eth_getUncleByBlockHashAndIndex",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_uncleByNumber(int param1, int param2) throw (jsonrpc::JsonRpcException)
Json::Value eth_getUncleByBlockNumberAndIndex(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("eth_uncleByNumber",p);
Json::Value result = this->CallMethod("eth_getUncleByBlockNumberAndIndex",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_compilers() throw (jsonrpc::JsonRpcException)
Json::Value eth_getCompilers() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("eth_compilers",p);
Json::Value result = this->CallMethod("eth_getCompilers",p);
if (result.isArray())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_lll(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_compileLLL(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_lll",p);
Json::Value result = this->CallMethod("eth_compileLLL",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_solidity(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_compileSerpent(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_solidity",p);
Json::Value result = this->CallMethod("eth_compileSerpent",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string eth_serpent(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_compileSolidity(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_serpent",p);
Json::Value result = this->CallMethod("eth_compileSolidity",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
int eth_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
std::string eth_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_newFilter",p);
if (result.isInt())
return result.asInt();
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
int eth_newFilterString(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_newBlockFilter(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_newFilterString",p);
if (result.isInt())
return result.asInt();
Json::Value result = this->CallMethod("eth_newBlockFilter",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_uninstallFilter(int param1) throw (jsonrpc::JsonRpcException)
bool eth_uninstallFilter(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
@ -397,31 +365,31 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_changed(int param1) throw (jsonrpc::JsonRpcException)
Json::Value eth_getFilterChanges(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_changed",p);
Json::Value result = this->CallMethod("eth_getFilterChanges",p);
if (result.isArray())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_filterLogs(int param1) throw (jsonrpc::JsonRpcException)
Json::Value eth_getFilterLogs(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_filterLogs",p);
Json::Value result = this->CallMethod("eth_getFilterLogs",p);
if (result.isArray())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_logs(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
Json::Value eth_getLogs(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_logs",p);
Json::Value result = this->CallMethod("eth_getLogs",p);
if (result.isArray())
return result;
else
@ -448,17 +416,17 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
int eth_register(const std::string& param1) throw (jsonrpc::JsonRpcException)
std::string eth_register(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_register",p);
if (result.isInt())
return result.asInt();
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool eth_unregister(int param1) throw (jsonrpc::JsonRpcException)
bool eth_unregister(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
@ -468,11 +436,11 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value eth_queuedTransactions(int param1) throw (jsonrpc::JsonRpcException)
Json::Value eth_fetchQueuedTransactions(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("eth_queuedTransactions",p);
Json::Value result = this->CallMethod("eth_fetchQueuedTransactions",p);
if (result.isArray())
return result;
else
@ -501,29 +469,6 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool db_putString(const std::string& param1, const std::string& param2, const std::string& param3) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
p.append(param3);
Json::Value result = this->CallMethod("db_putString",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string db_getString(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("db_getString",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool shh_post(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
@ -544,11 +489,11 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool shh_haveIdentity(const std::string& param1) throw (jsonrpc::JsonRpcException)
bool shh_hasIdentity(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("shh_haveIdentity",p);
Json::Value result = this->CallMethod("shh_hasIdentity",p);
if (result.isBool())
return result.asBool();
else
@ -576,17 +521,17 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
int shh_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
std::string shh_newFilter(const Json::Value& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("shh_newFilter",p);
if (result.isInt())
return result.asInt();
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool shh_uninstallFilter(int param1) throw (jsonrpc::JsonRpcException)
bool shh_uninstallFilter(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
@ -596,17 +541,17 @@ class WebThreeStubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value shh_changed(int param1) throw (jsonrpc::JsonRpcException)
Json::Value shh_getFilterChanges(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
Json::Value result = this->CallMethod("shh_changed",p);
Json::Value result = this->CallMethod("shh_getFilterChanges",p);
if (result.isArray())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value shh_getMessages(int param1) throw (jsonrpc::JsonRpcException)
Json::Value shh_getMessages(const std::string& param1) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);

2
third/MainWin.cpp

@ -540,7 +540,7 @@ void Main::timerEvent(QTimerEvent*)
for (auto const& i: m_handlers)
{
auto ls = ethereum()->checkWatch(i.first);
auto ls = ethereum()->checkWatchSafe(i.first);
if (ls.size())
i.second(ls);
}

Loading…
Cancel
Save