4
4
import io .api .etherscan .executor .IHttpExecutor ;
5
5
import io .api .etherscan .executor .impl .HttpExecutor ;
6
6
import io .api .etherscan .manager .IQueueManager ;
7
+ import io .api .etherscan .manager .impl .FakeQueueManager ;
7
8
import io .api .etherscan .manager .impl .QueueManager ;
8
9
import io .api .etherscan .model .EthNetwork ;
10
+ import io .api .etherscan .util .BasicUtils ;
9
11
10
12
import java .util .function .Supplier ;
11
13
@@ -28,6 +30,14 @@ public class EtherScanApi {
28
30
private final IStatisticApi stats ;
29
31
private final ITransactionApi txs ;
30
32
33
+ public EtherScanApi () {
34
+ this ("YourApiKeyToken" , EthNetwork .MAINNET );
35
+ }
36
+
37
+ public EtherScanApi (final EthNetwork network ) {
38
+ this ("YourApiKeyToken" , network );
39
+ }
40
+
31
41
public EtherScanApi (final String apiKey ) {
32
42
this (apiKey , EthNetwork .MAINNET );
33
43
}
@@ -40,20 +50,25 @@ public EtherScanApi(final String apiKey,
40
50
public EtherScanApi (final String apiKey ,
41
51
final EthNetwork network ,
42
52
final Supplier <IHttpExecutor > executorSupplier ) {
53
+ if (BasicUtils .isEmpty (apiKey ))
54
+ throw new NullPointerException ("API key can not be null" );
55
+
43
56
// EtherScan 5request\sec limit support by queue manager
44
- final IQueueManager masterQueue = new QueueManager (5 , 1 );
45
- final IHttpExecutor executor = executorSupplier .get ();
57
+ final IQueueManager masterQueue = (apiKey .equals ("YourApiKeyToken" ))
58
+ ? new FakeQueueManager ()
59
+ : new QueueManager (5 , 1 );
46
60
61
+ final IHttpExecutor executor = executorSupplier .get ();
47
62
final EthNetwork usedNetwork = (network == null ) ? EthNetwork .MAINNET : network ;
48
63
final String baseUrl = "https://" + usedNetwork .getDomain () + ".etherscan.io/api" + "?apikey=" + apiKey ;
49
64
50
65
this .account = new AccountApiProvider (masterQueue , baseUrl , executor );
51
- this .block = new BlockApiProvider (masterQueue , baseUrl , executor );
66
+ this .block = new BlockApiProvider (masterQueue , baseUrl , executor );
52
67
this .contract = new ContractApiProvider (masterQueue , baseUrl , executor );
53
- this .logs = new LogsApiProvider (masterQueue , baseUrl , executor );
54
- this .proxy = new ProxyApiProvider (masterQueue , baseUrl , executor );
55
- this .stats = new StatisticApiProvider (masterQueue , baseUrl , executor );
56
- this .txs = new TransactionApiProvider (masterQueue , baseUrl , executor );
68
+ this .logs = new LogsApiProvider (masterQueue , baseUrl , executor );
69
+ this .proxy = new ProxyApiProvider (masterQueue , baseUrl , executor );
70
+ this .stats = new StatisticApiProvider (masterQueue , baseUrl , executor );
71
+ this .txs = new TransactionApiProvider (masterQueue , baseUrl , executor );
57
72
}
58
73
59
74
public IContractApi contract () {
0 commit comments