forked from GoodforGod/java-etherscan-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiRunner.java
More file actions
60 lines (48 loc) · 1.74 KB
/
Copy pathApiRunner.java
File metadata and controls
60 lines (48 loc) · 1.74 KB
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
package io.api;
import io.api.etherscan.core.impl.EtherScanApi;
import io.api.etherscan.manager.impl.QueueManager;
import io.api.etherscan.model.EthNetwork;
import org.junit.AfterClass;
import org.junit.Assert;
public class ApiRunner extends Assert {
private static final EtherScanApi api;
private static final EtherScanApi apiRopsten;
private static final EtherScanApi apiRinkeby;
private static final EtherScanApi apiKovan;
private static final String apiKey;
static {
final String key = System.getenv("API_KEY");
apiKey = (key == null || key.isEmpty())
? EtherScanApi.DEFAULT_KEY
: key;
final QueueManager queueManager = (EtherScanApi.DEFAULT_KEY.equals(apiKey))
? QueueManager.DEFAULT_KEY_QUEUE
: new QueueManager(1, 1200L, 1200L, 0);
api = new EtherScanApi(ApiRunner.apiKey, EthNetwork.MAINNET, queueManager);
apiKovan = new EtherScanApi(ApiRunner.apiKey, EthNetwork.KOVAN, queueManager);
apiRopsten = new EtherScanApi(ApiRunner.apiKey, EthNetwork.ROPSTEN, queueManager);
apiRinkeby = new EtherScanApi(ApiRunner.apiKey, EthNetwork.RINKEBY, queueManager);
}
public static String getApiKey() {
return apiKey;
}
public static EtherScanApi getApi() {
return api;
}
public static EtherScanApi getApiRopsten() {
return apiRopsten;
}
public static EtherScanApi getApiRinkeby() {
return apiRinkeby;
}
public static EtherScanApi getApiKovan() {
return apiKovan;
}
@AfterClass
public static void cleanup() throws Exception {
api.close();
apiRopsten.close();
apiRinkeby.close();
apiKovan.close();
}
}