#470 Don't use admin_nodeInfo when get network_id

This commit is contained in:
Vlad Dobromyslov 2022-11-04 07:51:22 +02:00
parent d5d6390030
commit a30325660d
2 changed files with 10 additions and 9 deletions

View file

@ -15,9 +15,9 @@ class ethereum_rpc_client : public rpc_client {
public:
ethereum_rpc_client(const std::string &url, const std::string &user_name, const std::string &password, bool debug_rpc_calls);
std::string admin_node_info();
std::string eth_get_block_by_number(std::string block_number, bool full_block);
std::string eth_get_logs(std::string wallet_contract_address);
std::string eth_chainId();
std::string net_version();
std::string eth_get_transaction_count(const std::string &params);
std::string eth_gas_price();

View file

@ -28,10 +28,6 @@ ethereum_rpc_client::ethereum_rpc_client(const std::string &url, const std::stri
rpc_client(url, user_name, password, debug_rpc_calls) {
}
std::string ethereum_rpc_client::admin_node_info() {
return send_post_request("admin_nodeInfo", "", debug_rpc_calls);
}
std::string ethereum_rpc_client::eth_get_block_by_number(std::string block_number, bool full_block) {
const std::string params = "[ \"" + block_number + "\", " + (full_block ? "true" : "false") + "]";
return send_post_request("eth_getBlockByNumber", params, debug_rpc_calls);
@ -43,6 +39,10 @@ std::string ethereum_rpc_client::eth_get_logs(std::string wallet_contract_addres
return retrieve_value_from_reply(reply_str, "");
}
std::string ethereum_rpc_client::eth_chainId() {
return send_post_request("eth_chainId", "", debug_rpc_calls);
}
std::string ethereum_rpc_client::net_version() {
return send_post_request("net_version", "", debug_rpc_calls);
}
@ -56,13 +56,14 @@ std::string ethereum_rpc_client::eth_gas_price() {
}
std::string ethereum_rpc_client::get_chain_id() {
const std::string reply_str = net_version();
return retrieve_value_from_reply(reply_str, "");
const std::string reply_str = eth_chainId();
const auto chain_id_string = retrieve_value_from_reply(reply_str, "");
return chain_id_string.empty() ? "" : std::to_string(ethereum::from_hex<long long>(chain_id_string));
}
std::string ethereum_rpc_client::get_network_id() {
const std::string reply_str = admin_node_info();
return retrieve_value_from_reply(reply_str, "protocols.eth.network");
const std::string reply_str = net_version();
return retrieve_value_from_reply(reply_str, "");
}
std::string ethereum_rpc_client::get_nonce(const std::string &address) {