BitShares-Core  6.1.0
BitShares blockchain implementation and command-line interface software
operation_printer.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
25 
31 
32 #include <string>
33 #include <ostream>
34 
35 #include "wallet_api_impl.hpp"
36 
37 namespace graphene { namespace wallet { namespace detail {
38 
40 {
41 public:
43  : _wallet(w) {}
45  typedef std::string result_type;
46 
47  std::string operator()(const graphene::protocol::void_result& x) const;
48  std::string operator()(const graphene::protocol::object_id_type& oid) const;
49  std::string operator()(const graphene::protocol::asset& a) const;
50  std::string operator()(const graphene::protocol::generic_operation_result& r) const;
53 };
54 
55 // BLOCK TRX OP VOP
57 {
58 private:
59  std::ostream& out;
60  const wallet_api_impl& wallet;
63 
64  std::string format_asset(const graphene::protocol::asset& a) const;
65  void print_fee(const graphene::protocol::asset& a) const;
66 
67 public:
68  operation_printer( std::ostream& out, const wallet_api_impl& wallet,
70  : out(out),
71  wallet(wallet),
72  result(obj.result),
73  hist(obj)
74  {}
75 
77  typedef std::string result_type;
78 
79  template<typename T>
80  std::string operator()(const T& op)const
81  {
82  auto payer = wallet.get_account( op.fee_payer() );
83 
84  std::string op_name = fc::get_typename<T>::name();
85  if( op_name.find_last_of(':') != std::string::npos )
86  op_name.erase(0, op_name.find_last_of(':')+1);
87  out << op_name << " ";
88  out << payer.name;
89  print_fee( op.fee );
90  print_result();
91  return "";
92  }
93 
94  std::string operator()(const graphene::protocol::transfer_operation& op)const;
98  std::string operator()(const graphene::protocol::account_create_operation& op)const;
99  std::string operator()(const graphene::protocol::account_update_operation& op)const;
100  std::string operator()(const graphene::protocol::asset_create_operation& op)const;
101  std::string operator()(const graphene::protocol::asset_update_operation& op)const;
107  std::string operator()(const graphene::protocol::asset_issue_operation& op)const;
108  std::string operator()(const graphene::protocol::asset_reserve_operation& op)const;
109  std::string operator()(const graphene::protocol::asset_settle_operation& op)const;
113  std::string operator()(const graphene::protocol::fill_order_operation& op)const;
114  std::string operator()(const graphene::protocol::proposal_update_operation& op)const;
115  std::string operator()(const graphene::protocol::htlc_create_operation& op)const;
116  std::string operator()(const graphene::protocol::htlc_redeem_operation& op)const;
117  std::string operator()(const graphene::protocol::htlc_redeemed_operation& op)const;
118 
119 protected:
120  std::string print_memo( const fc::optional<graphene::protocol::memo_data>& memo)const;
121  void print_preimage( const std::vector<char>& preimage)const;
122  void print_redeem(const graphene::protocol::htlc_id_type& id,
123  const std::string& redeemer, const std::vector<char>& preimage,
124  const graphene::protocol::asset& op_fee)const;
125  void print_result()const;
126 };
127 
128 }}} // namespace graphene::wallet::detail
Update the set of feed-producing accounts for a BitAssetBitAssets have price feeds selected by taking...
Definition: asset_ops.hpp:430
operation_printer(std::ostream &out, const wallet_api_impl &wallet, const graphene::chain::operation_history_object &obj)
tracks the history of all logical operations on blockchain stateAll operations and virtual operations...
Definition: api.cpp:48
std::string operator()(const T &op) const
Update an existing account.
Definition: account.hpp:136
Schedules a market-issued asset for automatic settlementHolders of market-issued assests may request ...
Definition: asset_ops.hpp:267
Publish price feeds for market-issued assetsPrice feed providers use this operation to publish their ...
Definition: asset_ops.hpp:462
Allows the issuer of an asset to transfer an asset from any account to any account if they have overr...
Definition: transfer.hpp:77
used to take an asset out of circulation, returning to the issuer
Definition: asset_ops.hpp:513
Transfers an amount of one asset from one account to another.
Definition: transfer.hpp:45
std::string result_type
Return the decrypted memo if a memo exists, otherwise return an empty string.
Converts blinded/stealth balance to a public account balance.
instructs the blockchain to attempt to sell one asset for anotherThe blockchain will atempt to sell a...
Definition: market.hpp:48
Update options specific to BitAssetsBitAssets have some options which are not relevant to other asset...
Definition: asset_ops.hpp:398
std::string operator()(const graphene::protocol::void_result &x) const
Update options common to all assetsThere are a number of options which all assets in the network use...
Definition: asset_ops.hpp:351
Transfers BTS from the fee pool of a specified asset back to the issuer&#39;s balance.
Definition: asset_ops.hpp:601
The proposal_update_operation updates an existing transaction proposalThis operation allows accounts ...
Definition: proposal.hpp:119
account_object get_account(account_id_type id) const
Converts public account balance to a blinded or stealth balance.