32 #ifndef LEDGER_CORE_ETHEREUMLIKEACCOUNT_H 33 #define LEDGER_CORE_ETHEREUMLIKEACCOUNT_H 36 #include <api/AddressListCallback.hpp> 37 #include <api/Address.hpp> 38 #include <api/EthereumLikeAccount.hpp> 39 #include <api/EthereumLikeTransactionBuilder.hpp> 40 #include <api/StringCallback.hpp> 41 #include <api/Event.hpp> 42 #include <api/BigIntCallback.hpp> 43 #include <api/BigIntListCallback.hpp> 44 #include <wallet/common/AbstractWallet.hpp> 45 #include <wallet/common/AbstractAccount.hpp> 46 #include <wallet/common/Amount.h> 47 #include <wallet/ethereum/api_impl/InternalTransaction.h> 48 #include <wallet/ethereum/explorers/EthereumLikeBlockchainExplorer.h> 49 #include <wallet/ethereum/synchronizers/EthereumLikeAccountSynchronizer.h> 50 #include <wallet/ethereum/observers/EthereumLikeBlockchainObserver.h> 51 #include <wallet/ethereum/keychains/EthereumLikeKeychain.hpp> 52 #include <wallet/ethereum/ERC20/ERC20LikeAccount.h> 53 #include <wallet/ethereum/database/EthereumLikeAccountDatabaseEntry.h> 60 static const int FLAG_TRANSACTION_IGNORED = 0x00;
61 static const int FLAG_TRANSACTION_CREATED_SENDING_OPERATION = 0x01;
62 static const int FLAG_TRANSACTION_CREATED_RECEPTION_OPERATION = 0x01 << 1;
63 static const int FLAG_TRANSACTION_CREATED_EXTERNAL_OPERATION = 0x01 << 2;
67 const std::shared_ptr<EthereumLikeBlockchainExplorer>& explorer,
68 const std::shared_ptr<EthereumLikeBlockchainObserver>& observer,
69 const std::shared_ptr<EthereumLikeAccountSynchronizer>& synchronizer,
70 const std::shared_ptr<EthereumLikeKeychain>& keychain);
74 const std::shared_ptr<const AbstractWallet>& wallet,
81 void updateERC20Accounts(soci::session &sql,
const Operation &operation);
82 void updateERC20Operation(soci::session &sql,
85 void updateInternalTransactions(soci::session &sql,
const Operation &operation);
88 std::shared_ptr<EthereumLikeKeychain> getKeychain()
const;
93 getBalanceHistory(
const std::string & start,
94 const std::string & end,
95 api::TimePeriod precision)
override ;
99 std::shared_ptr<api::EventBus>
synchronize()
override ;
106 const std::string &txHash,
107 const std::vector<uint8_t> &rawTx);
109 void broadcastRawTransaction(
const std::vector<uint8_t> & transaction,
const std::shared_ptr<api::StringCallback> & callback)
override;
111 void broadcastTransaction(
const std::shared_ptr<api::EthereumLikeTransaction> & transaction,
112 const std::shared_ptr<api::StringCallback> & callback)
override;
114 std::shared_ptr<api::EthereumLikeTransactionBuilder>
buildTransaction()
override;
119 std::vector<std::shared_ptr<api::ERC20LikeAccount>>
getERC20Accounts()
override ;
121 void getGasPrice(
const std::shared_ptr<api::BigIntCallback> & callback)
override;
123 void getEstimatedGasLimit(
const std::string & address,
const std::shared_ptr<api::BigIntCallback> & callback)
override ;
125 void getERC20Balance(
const std::string & erc20Address,
const std::shared_ptr<api::BigIntCallback> & callback)
override;
127 void getERC20Balances(
const std::vector<std::string> &erc20Addresses,
const std::shared_ptr<api::BigIntListCallback> & callback)
override;
129 void addERC20Accounts(soci::session &sql,
130 const std::vector<ERC20LikeAccountDatabaseEntry> &erc20Entries);
134 std::shared_ptr<EthereumLikeAccount> getSelf();
135 std::shared_ptr<EthereumLikeKeychain> _keychain;
136 std::string _accountAddress;
137 std::shared_ptr<Preferences> _internalPreferences;
138 std::shared_ptr<Preferences> _externalPreferences;
139 std::shared_ptr<EthereumLikeBlockchainExplorer> _explorer;
140 std::shared_ptr<EthereumLikeAccountSynchronizer> _synchronizer;
141 std::shared_ptr<EthereumLikeBlockchainObserver> _observer;
142 std::shared_ptr<api::EventBus> _currentSyncEventBus;
143 std::mutex _synchronizationLock;
144 uint64_t _currentBlockHeight;
145 std::vector<ERC20LikeAccountDatabaseEntry> erc20Entries;
146 std::vector<std::shared_ptr<api::ERC20LikeAccount> >_erc20LikeAccounts;
151 #endif //LEDGER_CORE_ETHEREUMLIKEACCOUNT_H std::shared_ptr< api::EventBus > synchronize() override
Definition: EthereumLikeAccount.cpp:490
Definition: EthereumLikeBlockchainExplorer.h:71
void stopBlockchainObservation() override
Definition: EthereumLikeAccount.cpp:537
void startBlockchainObservation() override
Definition: EthereumLikeAccount.cpp:533
Definition: AbstractAccount.hpp:55
std::vector< std::shared_ptr< api::ERC20LikeAccount > > getERC20Accounts() override
Definition: EthereumLikeAccount.cpp:618
Definition: Deffered.hpp:49
std::shared_ptr< api::EthereumLikeTransactionBuilder > buildTransaction() override
Definition: EthereumLikeAccount.cpp:674
Definition: EthereumLikeAccount.h:57
Definition: Operation.h:53
bool isSynchronizing() override
Definition: EthereumLikeAccount.cpp:485
Definition: EthereumLikeBlockchainExplorer.h:53
bool isObservingBlockchain() override
Definition: EthereumLikeAccount.cpp:541
std::vector< Operation > getInternalOperations(soci::session &sql)
Get internal transactions related to the parent operation.
Definition: EthereumLikeAccount.cpp:261
Definition: EthereumLikeAccount.hpp:29
Definition: Account.cpp:8
std::shared_ptr< api::EthereumLikeAccount > asEthereumLikeAccount() override
Definition: EthereumLikeAccount.cpp:613
std::shared_ptr< api::OperationQuery > queryOperations() override
Definition: EthereumLikeAccount.cpp:351
std::string getRestoreKey() override
Definition: EthereumLikeAccount.cpp:545