28 namespace graphene {
namespace wallet {
namespace detail {
30 std::map< string, std::function< string( const fc::variant&, const fc::variants& ) >, std::less<> >
33 std::map< string, std::function< string( const fc::variant&, const fc::variants& ) >, std::less<> > m;
56 ss << b->timestamp.to_iso_string() <<
" ";
57 ss << string(i.
id) <<
" ";
65 m[
"get_account_history"] = format_account_history;
66 m[
"get_relative_account_history"] = format_account_history;
68 m[
"get_account_history_by_operations"] = [
this](
const variant& result,
const fc::variants&) {
72 ss <<
"result_count : " << r.result_count <<
" \n";
78 ss << b->timestamp.to_iso_string() <<
" ";
79 ss << string(i.
id) <<
" ";
81 ss <<
" transaction_id : ";
92 vector<asset_object> asset_recs;
98 for(
unsigned i = 0; i < asset_recs.size(); ++i )
99 ss << asset_recs[i].amount_to_pretty_string(r[i]) <<
"\n";
104 m[
"list_account_balances"] = format_balances;
105 m[
"get_blind_balances"] = format_balances;
110 std::stringstream ss;
113 for(
const auto& out : r.outputs )
115 auto a =
get_asset( out.decrypted_memo.amount.asset_id );
116 ss << a.amount_to_pretty_string( out.decrypted_memo.amount ) <<
" to " << out.label
117 <<
"\n\t receipt: " << out.confirmation_receipt <<
"\n\n";
122 m[
"transfer_to_blind"] = format_blind_transfers;
123 m[
"blind_transfer"] = format_blind_transfers;
128 std::stringstream ss;
129 auto as =
get_asset( r.amount.asset_id );
130 ss << as.amount_to_pretty_string( r.amount ) <<
" " << r.from_label <<
" => " 131 << r.to_label <<
" " << r.memo <<
"\n";
138 std::stringstream ss;
140 <<
" " <<
"AMOUNT" <<
" " <<
"FROM" <<
" => " <<
"TO" <<
" " <<
"MEMO" <<
"\n";
141 ss <<
"====================================================================================\n";
142 for(
auto& r : records )
144 auto as =
get_asset( r.amount.asset_id );
146 <<
" " << as.amount_to_pretty_string( r.amount ) <<
" " << r.from_label <<
" => " << r.to_label
147 <<
" " << r.memo <<
"\n";
155 auto bids = orders.
bids;
156 auto asks = orders.asks;
157 std::stringstream ss;
158 std::stringstream sum_stream;
159 sum_stream <<
"Sum(" << orders.base <<
')';
162 const int spacing = 20;
164 auto prettify_num = [&ss](
double n )
166 if (abs( round( n ) - n ) < 0.00000000001 )
170 else if (n - floor(n) < 0.000001)
172 ss << setiosflags( ios::fixed ) << setprecision(10) << n;
176 ss << setiosflags( ios::fixed ) << setprecision(6) << n;
179 auto prettify_num_string = [&](
string& num_string )
185 ss << setprecision( 8 ) << setiosflags( ios::fixed ) << setiosflags( ios::left );
187 ss <<
' ' << setw( (spacing * 4) + 6 ) <<
"BUY ORDERS" <<
"SELL ORDERS\n" 188 <<
' ' << setw( spacing + 1 ) <<
"Price" << setw( spacing ) << orders.quote <<
' ' << setw( spacing )
189 << orders.base <<
' ' << setw( spacing ) << sum_stream.str()
190 <<
" " << setw( spacing + 1 ) <<
"Price" << setw( spacing ) << orders.quote <<
' ' << setw( spacing )
191 << orders.base <<
' ' << setw( spacing ) << sum_stream.str()
192 <<
"\n=====================================================================================" 193 <<
"|=====================================================================================\n";
195 for (
unsigned int i = 0; i < bids.size() || i < asks.size() ; i++)
197 if ( i < bids.size() )
200 ss <<
' ' << setw( spacing );
201 prettify_num_string( bids[i].
price );
202 ss <<
' ' << setw( spacing );
203 prettify_num_string( bids[i].quote );
204 ss <<
' ' << setw( spacing );
205 prettify_num_string( bids[i].base );
206 ss <<
' ' << setw( spacing );
207 prettify_num( bid_sum );
212 ss << setw( (spacing * 4) + 5 ) <<
' ';
217 if ( i < asks.size() )
220 ss <<
' ' << setw( spacing );
221 prettify_num_string( asks[i].
price );
222 ss <<
' ' << setw( spacing );
223 prettify_num_string( asks[i].quote );
224 ss <<
' ' << setw( spacing );
225 prettify_num_string( asks[i].base );
226 ss <<
' ' << setw( spacing );
227 prettify_num( ask_sum );
234 <<
"Buy Total: " << bid_sum <<
' ' << orders.base << endl
235 <<
"Sell Total: " << ask_sum <<
' ' << orders.base << endl;
245 encapsulated << ENC_HEADER;
246 encapsulated << r.message <<
'\n';
247 encapsulated << ENC_META;
248 encapsulated <<
"account=" << r.meta.account <<
'\n';
249 encapsulated <<
"memokey=" << std::string( r.meta.memo_key ) <<
'\n';
250 encapsulated <<
"block=" << r.meta.block <<
'\n';
251 encapsulated <<
"timestamp=" << r.meta.time <<
'\n';
252 encapsulated << ENC_SIG;
253 encapsulated <<
fc::to_hex( (
const char*)r.signature->data(), r.signature->size() ) <<
'\n';
254 encapsulated << ENC_FOOTER;
256 return encapsulated.str();
extended_asset_object get_asset(asset_id_type id) const
std::string get_approximate_relative_time_string(const time_point_sec &event_time, const time_point_sec &relative_to_time=fc::time_point::now(), const std::string &ago=" ago")
std::map< string, std::function< string(const fc::variant &, const fc::variants &) >, std::less<> > get_result_formatters() const
vector< operation > operations
#define GRAPHENE_MAX_NESTED_OBJECTS
tracks the history of all logical operations on blockchain stateAll operations and virtual operations...
transaction_id_type transaction_id
std::vector< variant > variants
visitor::result_type visit(visitor &v)
fc::api< database_api > _remote_db
operation_history_object op
The price struct stores asset prices in the BitShares system.
double to_double(const std::string &)
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
T as(uint32_t max_depth) const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
typename impl::transform< List, Transformer >::type transform
Transform elements of a typelist.
const std::string & get_string() const
std::string to_hex(const char *d, uint32_t s)