Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
bidname_info_subcommand Struct Reference

Public Member Functions

 bidname_info_subcommand (CLI::App *actionRoot)
 

Public Attributes

bool print_json = false
 
string newname
 

Detailed Description

Definition at line 1611 of file main.cpp.

Constructor & Destructor Documentation

◆ bidname_info_subcommand()

bidname_info_subcommand::bidname_info_subcommand ( CLI::App * actionRoot)
inline

Definition at line 1614 of file main.cpp.

1614 {
1615 auto list_producers = actionRoot->add_subcommand("bidnameinfo", localized("Get bidname info"));
1616 list_producers->add_flag("--json,-j", print_json, localized("Output in JSON format"));
1617 list_producers->add_option("newname", newname, localized("The bidding name"))->required();
1618 list_producers->callback([this] {
1619 auto rawResult = call(get_table_func, fc::mutable_variant_object("json", true)
1620 ("code", "sysio")("scope", "sysio")("table", "namebids")
1621 ("lower_bound", name(newname).to_uint64_t())
1622 ("upper_bound", name(newname).to_uint64_t() + 1)
1623 // Less than ideal upper_bound usage preserved so clio can still work with old buggy nodeop versions
1624 // Change to newname.value when clio no longer needs to support nodeop versions older than 1.5.0
1625 ("limit", 1));
1626 if ( print_json ) {
1627 std::cout << fc::json::to_pretty_string(rawResult) << std::endl;
1628 return;
1629 }
1630 auto result = rawResult.as<sysio::chain_apis::read_only::get_table_rows_result>();
1631 // Condition in if statement below can simply be res.rows.empty() when clio no longer needs to support nodeop versions older than 1.5.0
1632 if( result.rows.empty() || result.rows[0].get_object()["newname"].as_string() != name(newname).to_string() ) {
1633 std::cout << "No bidname record found" << std::endl;
1634 return;
1635 }
1636 const auto& row = result.rows[0];
1637 string time = row["last_bid_time"].as_string();
1638 try {
1640 } catch (fc::parse_error_exception&) {
1641 }
1642 int64_t bid = row["high_bid"].as_int64();
1643 std::cout << std::left << std::setw(18) << "bidname:" << std::right << std::setw(24) << row["newname"].as_string() << "\n"
1644 << std::left << std::setw(18) << "highest bidder:" << std::right << std::setw(24) << row["high_bidder"].as_string() << "\n"
1645 << std::left << std::setw(18) << "highest bid:" << std::right << std::setw(24) << (bid > 0 ? bid : -bid) << "\n"
1646 << std::left << std::setw(18) << "last bid time:" << std::right << std::setw(24) << time << std::endl;
1647 if (bid < 0) std::cout << "This auction has already closed" << std::endl;
1648 });
1649 }
std::string name
Option * add_flag(std::string flag_name)
Add a flag with no description or variable assignment.
Definition CLI11.hpp:5265
App * add_subcommand(std::string subcommand_name="", std::string subcommand_description="")
Add a subcommand. Inherits INHERITABLE and OptionDefaults, and help flag.
Definition CLI11.hpp:5538
CRTP * required(bool value=true)
Set the option as required.
Definition CLI11.hpp:3400
static string to_pretty_string(const variant &v, const yield_function_t &yield, const output_formatting format=output_formatting::stringify_large_ints_and_doubles)
Definition json.cpp:775
An order-preserving dictionary of variants.
#define localized(str,...)
Definition localize.hpp:10
std::string string
Definition string.hpp:10
fc::string to_string(double)
Definition string.cpp:131
uint64_t to_uint64(const fc::string &)
Definition string.cpp:105
const string get_table_func
Definition httpc.hpp:94
fc::variant call(const std::string &url, const std::string &path, const T &v)
Definition main.cpp:258
signed __int64 int64_t
Definition stdint.h:135
Immutable except for fc::from_variant.
Definition name.hpp:43
Here is the call graph for this function:

Member Data Documentation

◆ newname

string bidname_info_subcommand::newname

Definition at line 1613 of file main.cpp.

◆ print_json

bool bidname_info_subcommand::print_json = false

Definition at line 1612 of file main.cpp.


The documentation for this struct was generated from the following file: