-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathEtherScanAPIProvider.java
95 lines (81 loc) · 2.64 KB
/
EtherScanAPIProvider.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package io.goodforgod.api.etherscan;
import io.goodforgod.api.etherscan.http.EthHttpClient;
import io.goodforgod.api.etherscan.manager.RequestQueueManager;
import org.jetbrains.annotations.NotNull;
/**
* EtherScan full API Description <a href="https://etherscan.io/apis">...</a>
*
* @author GoodforGod
* @since 28.10.2018
*/
final class EtherScanAPIProvider implements EtherScanAPI {
private final RequestQueueManager requestQueueManager;
private final AccountAPI account;
private final BlockAPI block;
private final ContractAPI contract;
private final LogsAPI logs;
private final ProxyAPI proxy;
private final StatisticAPI stats;
private final TransactionAPI txs;
private final GasTrackerAPI gasTracker;
EtherScanAPIProvider(String apiKey,
EthNetwork network,
RequestQueueManager queue,
EthHttpClient ethHttpClient,
Converter converter) {
// EtherScan 1request\5sec limit support by queue manager
final String baseUrl = network.domain() + "?apikey=" + apiKey;
this.requestQueueManager = queue;
this.account = new AccountAPIProvider(queue, baseUrl, ethHttpClient, converter);
this.block = new BlockAPIProvider(queue, baseUrl, ethHttpClient, converter);
this.contract = new ContractAPIProvider(queue, baseUrl, ethHttpClient, converter);
this.logs = new LogsAPIProvider(queue, baseUrl, ethHttpClient, converter);
this.proxy = new ProxyAPIProvider(queue, baseUrl, ethHttpClient, converter);
this.stats = new StatisticAPIProvider(queue, baseUrl, ethHttpClient, converter);
this.txs = new TransactionAPIProvider(queue, baseUrl, ethHttpClient, converter);
this.gasTracker = new GasTrackerAPIProvider(queue, baseUrl, ethHttpClient, converter);
}
@NotNull
@Override
public AccountAPI account() {
return account;
}
@NotNull
@Override
public ContractAPI contract() {
return contract;
}
@NotNull
@Override
public TransactionAPI txs() {
return txs;
}
@NotNull
@Override
public BlockAPI block() {
return block;
}
@NotNull
@Override
public LogsAPI logs() {
return logs;
}
@NotNull
@Override
public ProxyAPI proxy() {
return proxy;
}
@NotNull
@Override
public StatisticAPI stats() {
return stats;
}
@Override
public @NotNull GasTrackerAPI gasTracker() {
return gasTracker;
}
@Override
public void close() throws Exception {
requestQueueManager.close();
}
}