ledger-core
EthereumLikeBlockchainObserver.h
1 /*
2  *
3  * EthereumLikeBlockchainObserver
4  *
5  * Created by El Khalil Bellakrid on 14/07/2018.
6  *
7  * The MIT License (MIT)
8  *
9  * Copyright (c) 2018 Ledger
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a copy
12  * of this software and associated documentation files (the "Software"), to deal
13  * in the Software without restriction, including without limitation the rights
14  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15  * copies of the Software, and to permit persons to whom the Software is
16  * furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in all
19  * copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27  * SOFTWARE.
28  *
29  */
30 
31 
32 #ifndef LEDGER_CORE_ETHEREUMLIKEBLOCKCHAINOBSERVER_H
33 #define LEDGER_CORE_ETHEREUMLIKEBLOCKCHAINOBSERVER_H
34 
35 #include <string>
36 #include <list>
37 
38 #include <wallet/ethereum/explorers/EthereumLikeBlockchainExplorer.h>
39 
40 #include <utils/ConfigurationMatchable.h>
41 #include <async/DedicatedContext.hpp>
42 
43 #include <api/ExecutionContext.hpp>
44 #include <api/Currency.hpp>
45 #include <api/DynamicObject.hpp>
46 
47 #include <net/WebSocketClient.h>
48 #include <net/WebSocketConnection.h>
49 
50 #include <spdlog/logger.h>
51 #include <wallet/common/observers/AbstractBlockchainObserver.h>
52 namespace ledger {
53  namespace core {
54  class EthereumLikeAccount;
55  using EthereumBlockchainObserver = AbstractBlockchainObserver<EthereumLikeAccount, EthereumLikeBlockchainExplorerTransaction, EthereumLikeBlockchainExplorer::Block>;
57  public DedicatedContext,
58  public ConfigurationMatchable {
59  public:
60  EthereumLikeBlockchainObserver(const std::shared_ptr<api::ExecutionContext> &context,
61  const std::shared_ptr<api::DynamicObject> &configuration,
62  const std::shared_ptr<spdlog::logger> &logger,
63  const api::Currency &currency,
64  const std::vector<std::string> &matchableKeys);
65 
66 
67  protected:
68  void putTransaction(const EthereumLikeBlockchainExplorerTransaction &tx) override;
69 
70  void putBlock(const EthereumLikeBlockchainExplorer::Block &block) override;
71 
72  const api::Currency &getCurrency() const {
73  return _currency;
74  };
75 
76  std::shared_ptr<api::DynamicObject> getConfiguration() const {
77  return _configuration;
78  };
79 
80  private:
81  api::Currency _currency;
82  std::shared_ptr<api::DynamicObject> _configuration;
83  };
84  }
85 }
86 
87 
88 #endif //LEDGER_CORE_ETHEREUMLIKEBLOCKCHAINOBSERVER_H
Definition: EthereumLikeBlockchainExplorer.h:71
Definition: AbstractBlockchainObserver.h:45
Definition: EthereumLikeBlockchainObserver.h:56
Definition: ConfigurationMatchable.h:38
Definition: Currency.hpp:23
Definition: Account.cpp:8
Definition: DedicatedContext.hpp:39
Definition: Block.h:40
Definition: logger.hpp:44