ledger-core
OperationApi.h
1 /*
2  *
3  * OperationApi
4  * ledger-core
5  *
6  * Created by Pierre Pollastri on 03/07/2017.
7  *
8  * The MIT License (MIT)
9  *
10  * Copyright (c) 2016 Ledger
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy
13  * of this software and associated documentation files (the "Software"), to deal
14  * in the Software without restriction, including without limitation the rights
15  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16  * copies of the Software, and to permit persons to whom the Software is
17  * furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included in all
20  * copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28  * SOFTWARE.
29  *
30  */
31 #ifndef LEDGER_CORE_OPERATIONAPI_H
32 #define LEDGER_CORE_OPERATIONAPI_H
33 
34 #include <api/Operation.hpp>
35 #include <wallet/common/Operation.h>
36 #include <api/Currency.hpp>
37 
38 namespace ledger {
39  namespace core {
40  class AbstractAccount;
41  class OperationApi : public api::Operation, public std::enable_shared_from_this<OperationApi> {
42  public:
43  OperationApi(const std::shared_ptr<AbstractAccount>& account);
44  std::string getUid() override;
45  int32_t getAccountIndex() override;
46  api::OperationType getOperationType() override;
47  std::chrono::system_clock::time_point getDate() override;
48  std::vector<std::string> getSenders() override;
49  std::vector<std::string> getRecipients() override;
50  std::shared_ptr<api::Amount> getAmount() override;
51  std::shared_ptr<api::Amount> getFees() override;
52  std::shared_ptr<api::Preferences> getPreferences() override;
53  std::shared_ptr<api::TrustIndicator> getTrust() override;
54  std::shared_ptr<api::BitcoinLikeOperation> asBitcoinLikeOperation() override;
55  std::shared_ptr<api::EthereumLikeOperation> asEthereumLikeOperation() override;
56  std::shared_ptr<api::RippleLikeOperation> asRippleLikeOperation() override;
57  std::shared_ptr<api::TezosLikeOperation> asTezosLikeOperation() override;
59  bool isInstanceOfBitcoinLikeOperation() override;
60  bool isInstanceOfEthereumLikeOperation() override;
61  bool isInstanceOfRippleLikeOperation() override;
62  bool isInstanceOfTezosLikeOperation() override;
63  bool isComplete() override;
64  api::WalletType getWalletType() override;
65  ledger::core::Operation& getBackend();
66  const std::shared_ptr<AbstractAccount>& getAccount() const;
67 
68  api::Currency getCurrency() override;
69 
70  private:
71  ledger::core::Operation _backend;
72  std::shared_ptr<AbstractAccount> _account;
73  std::shared_ptr<api::Amount> _fees;
74  std::shared_ptr<api::Amount> _amount;
75  };
76  }
77 }
78 
79 
80 #endif //LEDGER_CORE_OPERATIONAPI_H
std::shared_ptr< api::Amount > getAmount() override
Definition: OperationApi.cpp:129
std::shared_ptr< api::TrustIndicator > getTrust() override
Definition: OperationApi.cpp:108
std::string getUid() override
Definition: OperationApi.cpp:47
api::Currency getCurrency() override
Definition: OperationApi.cpp:165
bool isInstanceOfTezosLikeOperation() override
Definition: OperationApi.cpp:91
std::shared_ptr< api::Amount > getFees() override
Definition: OperationApi.cpp:122
std::shared_ptr< api::BitcoinLikeOperation > asBitcoinLikeOperation() override
Definition: OperationApi.cpp:133
optional< int64_t > getBlockHeight() override
Definition: OperationApi.cpp:116
bool isComplete() override
Definition: OperationApi.cpp:95
int32_t getAccountIndex() override
Definition: OperationApi.cpp:51
std::shared_ptr< api::Preferences > getPreferences() override
Definition: OperationApi.cpp:112
std::shared_ptr< api::RippleLikeOperation > asRippleLikeOperation() override
Definition: OperationApi.cpp:147
Definition: OperationApi.h:41
bool isInstanceOfEthereumLikeOperation() override
Definition: OperationApi.cpp:83
std::vector< std::string > getSenders() override
Definition: OperationApi.cpp:63
Definition: Operation.h:53
api::WalletType getWalletType() override
Definition: OperationApi.cpp:75
bool isInstanceOfRippleLikeOperation() override
Definition: OperationApi.cpp:87
Definition: Currency.hpp:23
Definition: Account.cpp:8
std::shared_ptr< api::TezosLikeOperation > asTezosLikeOperation() override
Definition: OperationApi.cpp:154
std::shared_ptr< api::EthereumLikeOperation > asEthereumLikeOperation() override
Definition: OperationApi.cpp:140
WalletType
Definition: WalletType.hpp:20
Definition: Operation.hpp:35
std::chrono::system_clock::time_point getDate() override
Definition: OperationApi.cpp:59
std::vector< std::string > getRecipients() override
Definition: OperationApi.cpp:67
api::OperationType getOperationType() override
Definition: OperationApi.cpp:55
Definition: optional.hpp:177
bool isInstanceOfBitcoinLikeOperation() override
Definition: OperationApi.cpp:79