solidity/ethstubclient.h

454 lines
14 KiB
C
Raw Normal View History

2014-10-13 09:22:28 +00:00
/**
* THIS FILE IS GENERATED BY jsonrpcstub, DO NOT CHANGE IT!!!!!
*/
#ifndef _ETHSTUBCLIENT_H_
#define _ETHSTUBCLIENT_H_
#include <jsonrpc/rpc.h>
class EthStubClient
{
public:
EthStubClient(jsonrpc::AbstractClientConnector* conn)
{
this->client = new jsonrpc::Client(conn);
}
~EthStubClient()
{
delete this->client;
}
2014-10-15 09:49:53 +00:00
std::string balanceAt(const std::string& address, const int& block) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
2014-10-15 09:49:53 +00:00
p["address"] = address;
2014-10-13 09:22:28 +00:00
p["block"] = block;
Json::Value result = this->client->CallMethod("balanceAt",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-16 01:46:47 +00:00
Json::Value block(const Json::Value& params) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
2014-10-16 01:46:47 +00:00
p["params"] = params;
2014-10-13 09:22:28 +00:00
Json::Value result = this->client->CallMethod("block",p);
2014-10-14 11:13:30 +00:00
if (result.isObject())
2014-10-13 09:22:28 +00:00
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string call(const Json::Value& json) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["json"] = json;
Json::Value result = this->client->CallMethod("call",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-16 11:06:24 +00:00
bool check(const int& id) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["id"] = id;
Json::Value result = this->client->CallMethod("check",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-15 09:49:53 +00:00
std::string codeAt(const std::string& address, const int& block) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
2014-10-15 09:49:53 +00:00
p["address"] = address;
2014-10-13 09:22:28 +00:00
p["block"] = block;
Json::Value result = this->client->CallMethod("codeAt",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string coinbase() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->client->CallMethod("coinbase",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-15 09:49:53 +00:00
double countAt(const std::string& address, const int& block) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
2014-10-15 09:49:53 +00:00
p["address"] = address;
2014-10-13 09:22:28 +00:00
p["block"] = block;
Json::Value result = this->client->CallMethod("countAt",p);
2014-10-14 11:10:16 +00:00
if (result.isDouble())
return result.asDouble();
2014-10-13 09:22:28 +00:00
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
int defaultBlock() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->client->CallMethod("defaultBlock",p);
if (result.isInt())
return result.asInt();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string fromAscii(const int& padding, const std::string& s) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["padding"] = padding;
p["s"] = s;
Json::Value result = this->client->CallMethod("fromAscii",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
double fromFixed(const std::string& s) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["s"] = s;
Json::Value result = this->client->CallMethod("fromFixed",p);
if (result.isDouble())
return result.asDouble();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string gasPrice() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->client->CallMethod("gasPrice",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string key() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->client->CallMethod("key",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value keys() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->client->CallMethod("keys",p);
if (result.isArray())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-16 11:06:24 +00:00
bool killWatch(const int& id) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["id"] = id;
Json::Value result = this->client->CallMethod("killWatch",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-14 15:24:51 +00:00
bool listening() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->client->CallMethod("listening",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-13 09:22:28 +00:00
std::string lll(const std::string& s) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["s"] = s;
Json::Value result = this->client->CallMethod("lll",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-16 01:46:47 +00:00
Json::Value messages(const Json::Value& params) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
2014-10-16 01:46:47 +00:00
p["params"] = params;
2014-10-13 09:22:28 +00:00
Json::Value result = this->client->CallMethod("messages",p);
if (result.isArray())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
2014-10-14 15:24:51 +00:00
}
bool mining() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->client->CallMethod("mining",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
2014-10-13 09:22:28 +00:00
}
int number() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->client->CallMethod("number",p);
if (result.isInt())
return result.asInt();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
int peerCount() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->client->CallMethod("peerCount",p);
if (result.isInt())
return result.asInt();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string secretToAddress(const std::string& s) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["s"] = s;
Json::Value result = this->client->CallMethod("secretToAddress",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-14 19:53:11 +00:00
bool setCoinbase(const std::string& address) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["address"] = address;
Json::Value result = this->client->CallMethod("setCoinbase",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-14 20:01:07 +00:00
bool setListening(const bool& listening) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
2014-10-14 20:01:07 +00:00
p["listening"] = listening;
2014-10-13 09:22:28 +00:00
Json::Value result = this->client->CallMethod("setListening",p);
2014-10-14 19:53:11 +00:00
if (result.isBool())
return result.asBool();
2014-10-13 09:22:28 +00:00
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-14 20:01:07 +00:00
bool setMining(const bool& mining) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
2014-10-14 20:01:07 +00:00
p["mining"] = mining;
2014-10-13 09:22:28 +00:00
Json::Value result = this->client->CallMethod("setMining",p);
2014-10-14 19:53:11 +00:00
if (result.isBool())
return result.asBool();
2014-10-13 09:22:28 +00:00
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string sha3(const std::string& s) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["s"] = s;
Json::Value result = this->client->CallMethod("sha3",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-15 09:49:53 +00:00
std::string stateAt(const std::string& address, const int& block, const std::string& storage) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
2014-10-15 09:49:53 +00:00
p["address"] = address;
2014-10-13 09:22:28 +00:00
p["block"] = block;
2014-10-15 09:49:53 +00:00
p["storage"] = storage;
2014-10-13 09:22:28 +00:00
Json::Value result = this->client->CallMethod("stateAt",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string toAscii(const std::string& s) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["s"] = s;
Json::Value result = this->client->CallMethod("toAscii",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string toDecimal(const std::string& s) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["s"] = s;
Json::Value result = this->client->CallMethod("toDecimal",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string toFixed(const double& s) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["s"] = s;
Json::Value result = this->client->CallMethod("toFixed",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-14 11:10:16 +00:00
std::string transact(const Json::Value& json) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
p["json"] = json;
Json::Value result = this->client->CallMethod("transact",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-16 01:46:47 +00:00
Json::Value transaction(const int& i, const Json::Value& params) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
p["i"] = i;
2014-10-16 01:46:47 +00:00
p["params"] = params;
2014-10-13 09:22:28 +00:00
Json::Value result = this->client->CallMethod("transaction",p);
2014-10-14 11:13:30 +00:00
if (result.isObject())
2014-10-13 09:22:28 +00:00
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-16 01:46:47 +00:00
Json::Value uncle(const int& i, const Json::Value& params) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
p["i"] = i;
2014-10-16 01:46:47 +00:00
p["params"] = params;
2014-10-13 09:22:28 +00:00
Json::Value result = this->client->CallMethod("uncle",p);
2014-10-14 11:13:30 +00:00
if (result.isObject())
2014-10-13 09:22:28 +00:00
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
2014-10-16 11:06:24 +00:00
int watch(const std::string& params) throw (jsonrpc::JsonRpcException)
2014-10-13 09:22:28 +00:00
{
Json::Value p;
2014-10-16 01:46:47 +00:00
p["params"] = params;
2014-10-13 09:22:28 +00:00
Json::Value result = this->client->CallMethod("watch",p);
2014-10-16 11:06:24 +00:00
if (result.isInt())
return result.asInt();
2014-10-13 09:22:28 +00:00
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
private:
jsonrpc::Client* client;
};
#endif //_ETHSTUBCLIENT_H_