Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleos v2 #123

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b8cdf68
cleos: implement HTTP GET.
pnx Mar 4, 2019
e48a775
cleos: adding "get creator" command
pnx Mar 4, 2019
1040f5d
cleos: adding "get transacted_accounts" command
pnx Mar 5, 2019
1d4ac46
cleos: adding "get abi_snapshot" command.
pnx Mar 6, 2019
064389c
cleos: adding "get root_actions" command.
pnx Mar 6, 2019
8df0c49
cleos: change "get transaction" command to version 2.
pnx Mar 6, 2019
66e491f
cleos: adding helpers module.
pnx Mar 7, 2019
e1f4ae6
programs/cleos/main.cpp: in get_root_actions_subcommand, skip _fixDat…
pnx Mar 7, 2019
44e2190
cleos: adding "get transfers" command
pnx Mar 8, 2019
6bd3f73
cleos: change "get accounts" command to use version 2
pnx Mar 8, 2019
29e57cf
cleos: adding "--legacy-api" flag to allow "get transaction" and "get…
pnx Mar 9, 2019
6310bdc
programs/cleos/httpc.hpp: "get_key_accounts_v2_func" is now under "st…
pnx Mar 11, 2019
33336ee
cleos: adding "get created_accounts" command.
pnx Mar 13, 2019
3ee11b6
programs/cleos/main.cpp: indentation fix.
pnx Mar 14, 2019
7cdf550
programs/cleos/main.cpp: adding "-j,--json" flags to v2 commands.
pnx Mar 14, 2019
00c096b
programs/cleos/main.cpp: adding "(v2)" to description strings.
pnx Mar 14, 2019
c2a25b9
cleos: merge "get abi" and "get abi_snapshot" adding "block" as a par…
pnx Mar 15, 2019
37e33f4
cloes: move "get creator" to a struct.
pnx Mar 15, 2019
45d2191
cleos: adding "get deltas" command
pnx Mar 15, 2019
1720913
cleos: adding "get tokens" command.
pnx Mar 19, 2019
b8b2902
cleos: move "get created_accounts" to submenu -> "get created accounts"
pnx Apr 2, 2019
8c22fdd
cleos: move "get transacted_accounts" to submenu -> "get transacted a…
pnx Apr 2, 2019
0c69752
cleos: adding "get voters" command
pnx Sep 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions programs/cleos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
configure_file(help_text.cpp.in help_text.cpp @ONLY)
add_executable( ${CLI_CLIENT_EXECUTABLE_NAME} main.cpp httpc.cpp ${CMAKE_CURRENT_BINARY_DIR}/help_text.cpp localize.hpp config.hpp CLI11.hpp)
add_executable( ${CLI_CLIENT_EXECUTABLE_NAME} main.cpp httpc.cpp helpers.cpp ${CMAKE_CURRENT_BINARY_DIR}/help_text.cpp localize.hpp config.hpp CLI11.hpp)
if( UNIX AND NOT APPLE )
set(rt_library rt )
endif()
Expand Down Expand Up @@ -37,7 +37,7 @@ target_include_directories(${CLI_CLIENT_EXECUTABLE_NAME} PUBLIC ${Intl_INCLUDE_D

target_link_libraries( ${CLI_CLIENT_EXECUTABLE_NAME}
PRIVATE appbase chain_api_plugin producer_plugin chain_plugin http_plugin eosio_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ${Intl_LIBRARIES} )


copy_bin( ${CLI_CLIENT_EXECUTABLE_NAME} )
install( TARGETS
Expand Down
26 changes: 26 additions & 0 deletions programs/cleos/helpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include <cctype>
#include "helpers.hpp"

namespace eosio { namespace client { namespace helpers {

std::string& url_encode(std::string& str) {

char hex[17] = "0123456789ABCDEF";

for(int i = 0; i < str.length(); i++) {

char ch = str[i];

if (!(isalnum(ch) || ch == '-' || ch == '_' || ch == '.' || ch == '~') ) {
std::string rep = "%";
rep += hex[(ch & 0xF0) >> 4];
rep += hex[ch & 0x0F];
str.replace(i, 1, rep);
i += 2;
}
}
return str;
}

}}}
13 changes: 13 additions & 0 deletions programs/cleos/helpers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @file
* @copyright defined in eos/LICENSE
*/
#pragma once

#include <string>

namespace eosio { namespace client { namespace helpers {

std::string& url_encode(std::string& str);

}}}
3 changes: 2 additions & 1 deletion programs/cleos/httpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ namespace eosio { namespace client { namespace http {
}

fc::variant do_http_call( const connection_param& cp,
const string& method,
const fc::variant& postdata,
bool print_request,
bool print_response ) {
Expand All @@ -197,7 +198,7 @@ namespace eosio { namespace client { namespace http {
boost::asio::streambuf request;
std::ostream request_stream(&request);
auto host_header_value = format_host_header(url);
request_stream << "POST " << url.path << " HTTP/1.0\r\n";
request_stream << method << " " << url.path << " HTTP/1.0\r\n";
request_stream << "Host: " << host_header_value << "\r\n";
request_stream << "content-length: " << postjson.size() << "\r\n";
request_stream << "Accept: */*\r\n";
Expand Down
14 changes: 14 additions & 0 deletions programs/cleos/httpc.hpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace eosio { namespace client { namespace http {

fc::variant do_http_call(
const connection_param& cp,
const string& method = "GET",
const fc::variant& postdata = fc::variant(),
bool print_request = false,
bool print_response = false);
Expand Down Expand Up @@ -110,6 +111,19 @@ namespace eosio { namespace client { namespace http {
const string get_key_accounts_func = history_func_base + "/get_key_accounts";
const string get_controlled_accounts_func = history_func_base + "/get_controlled_accounts";

// v2
const string get_voters_func = "/v2/state/get_voters";
const string get_key_accounts_v2_func = "/v2/state/get_key_accounts";
const string get_deltas_func = "/v2/history/get_deltas";
const string get_creator_func = "/v2/history/get_creator";
const string get_created_accounts_func = "/v2/history/get_created_accounts";
const string get_transaction_v2_func = "/v2/history/get_transaction";
const string get_transacted_accounts_func = "/v2/history/get_transacted_accounts";
const string get_abi_snapshot_func = "/v2/history/get_abi_snapshot";
const string get_root_actions_func = "/v2/history/get_actions";
const string get_transfers_func = "/v2/history/get_transfers";
const string get_tokens_func = "/v2/state/get_tokens";

const string net_func_base = "/v1/net";
const string net_connect = net_func_base + "/connect";
const string net_disconnect = net_func_base + "/disconnect";
Expand Down
Loading