Skip to content

Commit

Permalink
Merge branch 'testnet' into block-generation
Browse files Browse the repository at this point in the history
  • Loading branch information
SpyCheese committed Oct 17, 2023
2 parents 3c55abf + 7f815fc commit ac08fd6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tonlib/tonlib/tonlib-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ class TonlibCli : public td::actor::Actor {
"<addr> with specified parameters\n";
td::TerminalIO::out() << "getstate <key_id>\tget state of wallet with requested key\n";
td::TerminalIO::out() << "getstatebytransaction <key_id> <lt> <hash>\tget state of wallet with requested key after transaction with local time <lt> and hash <hash> (base64url)\n";
td::TerminalIO::out() << "getconfig <param>\tshow specified configuration parameter from the latest masterchain state\n";
td::TerminalIO::out() << "guessrevision <key_id>\tsearch of existing accounts corresponding to the given key\n";
td::TerminalIO::out() << "guessaccount <key_id>\tsearch of existing accounts corresponding to the given key\n";
td::TerminalIO::out() << "getaddress <key_id>\tget address of wallet with requested key\n";
Expand Down Expand Up @@ -487,6 +488,8 @@ class TonlibCli : public td::actor::Actor {
get_state(parser.read_word(), std::move(cmd_promise));
} else if (cmd == "getstatebytransaction") {
get_state_by_transaction(parser, std::move(cmd_promise));
} else if (cmd == "getconfig") {
get_config_param(parser, std::move(cmd_promise));
} else if (cmd == "getaddress") {
get_address(parser.read_word(), std::move(cmd_promise));
} else if (cmd == "importkeypem") {
Expand Down Expand Up @@ -2089,6 +2092,26 @@ class TonlibCli : public td::actor::Actor {
}));
}

void get_config_param(td::ConstParser& parser, td::Promise<td::Unit> promise) {
TRY_RESULT_PROMISE(promise, param, td::to_integer_safe<td::int32>(parser.read_word()));
send_query(make_object<tonlib_api::getConfigParam>(0, param),
promise.wrap([param](auto&& result) -> td::Result<td::Unit> {
TRY_RESULT(cell, vm::std_boc_deserialize(result->config_->bytes_, true));
if (cell.is_null()) {
td::TerminalIO::out() << "ConfigParam(" << param << ") = (null)\n";
return td::Unit();
}
std::ostringstream os;
if (param >= 0) {
block::gen::ConfigParam{param}.print_ref(4096, os, cell);
os << "\n";
}
vm::load_cell_slice(cell).print_rec(4096, os);
td::TerminalIO::out() << "ConfigParam(" << param << ") = " << os.str() << "\n";
return td::Unit();
}));
}

void get_address(td::Slice key, td::Promise<td::Unit> promise) {
TRY_RESULT_PROMISE(promise, address, to_account_address(key, false));
promise.set_value(td::Unit());
Expand Down

0 comments on commit ac08fd6

Please sign in to comment.