Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0480bf3

Browse files
committed
Add support for PolygonScan
1 parentcafcdff commit0480bf3

File tree

7 files changed

+373
-116
lines changed

7 files changed

+373
-116
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
packageio.api.etherscan.core.impl;
2+
3+
importio.api.etherscan.core.*;
4+
importio.api.etherscan.error.ApiException;
5+
importio.api.etherscan.error.ApiKeyException;
6+
importio.api.etherscan.executor.IHttpExecutor;
7+
importio.api.etherscan.executor.impl.HttpExecutor;
8+
importio.api.etherscan.manager.IQueueManager;
9+
importio.api.etherscan.manager.impl.FakeQueueManager;
10+
importio.api.etherscan.manager.impl.QueueManager;
11+
importio.api.etherscan.model.EthNetwork;
12+
importio.api.etherscan.model.network.Network;
13+
importio.api.etherscan.util.BasicUtils;
14+
importorg.jetbrains.annotations.NotNull;
15+
16+
importjava.util.function.Supplier;
17+
18+
publicabstractclassBaseApiimplementsAutoCloseable {
19+
20+
privatestaticfinalSupplier<IHttpExecutor>DEFAULT_SUPPLIER =HttpExecutor::new;
21+
22+
publicstaticfinalStringDEFAULT_KEY ="YourApiKeyToken";
23+
24+
privatefinalIQueueManagerqueueManager;
25+
privatefinalIAccountApiaccount;
26+
privatefinalIBlockApiblock;
27+
privatefinalIContractApicontract;
28+
privatefinalILogsApilogs;
29+
privatefinalIProxyApiproxy;
30+
privatefinalIStatisticApistats;
31+
privatefinalITransactionApitxs;
32+
33+
publicBaseApi() {
34+
this(DEFAULT_KEY,EthNetwork.MAINNET);
35+
}
36+
37+
publicBaseApi(finalNetworknetwork) {
38+
this(DEFAULT_KEY,network);
39+
}
40+
41+
publicBaseApi(finalStringapiKey) {
42+
this(apiKey,EthNetwork.MAINNET);
43+
}
44+
45+
publicBaseApi(finalNetworknetwork,
46+
finalSupplier<IHttpExecutor>executorSupplier) {
47+
this(DEFAULT_KEY,network,executorSupplier);
48+
}
49+
50+
publicBaseApi(finalStringapiKey,
51+
finalNetworknetwork,
52+
finalIQueueManagerqueue) {
53+
this(apiKey,network,DEFAULT_SUPPLIER,queue);
54+
}
55+
56+
publicBaseApi(finalStringapiKey,
57+
finalNetworknetwork) {
58+
this(apiKey,network,DEFAULT_SUPPLIER);
59+
}
60+
61+
publicBaseApi(finalStringapiKey,
62+
finalNetworknetwork,
63+
finalSupplier<IHttpExecutor>executorSupplier) {
64+
this(apiKey,network,executorSupplier,
65+
DEFAULT_KEY.equals(apiKey)
66+
?QueueManager.DEFAULT_KEY_QUEUE
67+
:newFakeQueueManager());
68+
}
69+
70+
publicBaseApi(finalStringapiKey,
71+
finalNetworknetwork,
72+
finalSupplier<IHttpExecutor>executorSupplier,
73+
finalIQueueManagerqueue) {
74+
if (BasicUtils.isBlank(apiKey))
75+
thrownewApiKeyException("API key can not be null or empty");
76+
77+
if (network ==null)
78+
thrownewApiException("Ethereum Network is set to NULL value");
79+
80+
// EtherScan 1request\5sec limit support by queue manager
81+
finalIHttpExecutorexecutor =executorSupplier.get();
82+
83+
finalStringbaseUrl =network.getUrl() +apiKey;
84+
85+
this.queueManager =queue;
86+
this.account =newAccountApiProvider(queue,baseUrl,executor);
87+
this.block =newBlockApiProvider(queue,baseUrl,executor);
88+
this.contract =newContractApiProvider(queue,baseUrl,executor);
89+
this.logs =newLogsApiProvider(queue,baseUrl,executor);
90+
this.proxy =newProxyApiProvider(queue,baseUrl,executor);
91+
this.stats =newStatisticApiProvider(queue,baseUrl,executor);
92+
this.txs =newTransactionApiProvider(queue,baseUrl,executor);
93+
}
94+
95+
@NotNull
96+
publicIAccountApiaccount() {
97+
returnaccount;
98+
}
99+
100+
@NotNull
101+
publicIContractApicontract() {
102+
returncontract;
103+
}
104+
105+
@NotNull
106+
publicITransactionApitxs() {
107+
returntxs;
108+
}
109+
110+
@NotNull
111+
publicIBlockApiblock() {
112+
returnblock;
113+
}
114+
115+
@NotNull
116+
publicILogsApilogs() {
117+
returnlogs;
118+
}
119+
120+
@NotNull
121+
publicIProxyApiproxy() {
122+
returnproxy;
123+
}
124+
125+
@NotNull
126+
publicIStatisticApistats() {
127+
returnstats;
128+
}
129+
130+
@Override
131+
publicvoidclose()throwsException {
132+
queueManager.close();
133+
}
134+
135+
}
Lines changed: 16 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
packageio.api.etherscan.core.impl;
22

3-
importio.api.etherscan.core.*;
4-
importio.api.etherscan.error.ApiException;
5-
importio.api.etherscan.error.ApiKeyException;
63
importio.api.etherscan.executor.IHttpExecutor;
7-
importio.api.etherscan.executor.impl.HttpExecutor;
84
importio.api.etherscan.manager.IQueueManager;
9-
importio.api.etherscan.manager.impl.FakeQueueManager;
10-
importio.api.etherscan.manager.impl.QueueManager;
115
importio.api.etherscan.model.EthNetwork;
12-
importio.api.etherscan.util.BasicUtils;
13-
importorg.jetbrains.annotations.NotNull;
146

157
importjava.util.function.Supplier;
168

@@ -20,121 +12,37 @@
2012
* @author GoodforGod
2113
* @since 28.10.2018
2214
*/
23-
publicclassEtherScanApiimplementsAutoCloseable {
24-
25-
privatestaticfinalSupplier<IHttpExecutor>DEFAULT_SUPPLIER =HttpExecutor::new;
26-
27-
publicstaticfinalStringDEFAULT_KEY ="YourApiKeyToken";
28-
29-
privatefinalIQueueManagerqueueManager;
30-
privatefinalIAccountApiaccount;
31-
privatefinalIBlockApiblock;
32-
privatefinalIContractApicontract;
33-
privatefinalILogsApilogs;
34-
privatefinalIProxyApiproxy;
35-
privatefinalIStatisticApistats;
36-
privatefinalITransactionApitxs;
15+
publicclassEtherScanApiextendsBaseApi {
3716

3817
publicEtherScanApi() {
39-
this(DEFAULT_KEY,EthNetwork.MAINNET);
40-
}
41-
42-
publicEtherScanApi(finalEthNetworknetwork) {
43-
this(DEFAULT_KEY,network);
44-
}
45-
46-
publicEtherScanApi(finalStringapiKey) {
47-
this(apiKey,EthNetwork.MAINNET);
48-
}
49-
50-
publicEtherScanApi(finalEthNetworknetwork,
51-
finalSupplier<IHttpExecutor>executorSupplier) {
52-
this(DEFAULT_KEY,network,executorSupplier);
53-
}
54-
55-
publicEtherScanApi(finalStringapiKey,
56-
finalEthNetworknetwork,
57-
finalIQueueManagerqueue) {
58-
this(apiKey,network,DEFAULT_SUPPLIER,queue);
59-
}
60-
61-
publicEtherScanApi(finalStringapiKey,
62-
finalEthNetworknetwork) {
63-
this(apiKey,network,DEFAULT_SUPPLIER);
64-
}
65-
66-
publicEtherScanApi(finalStringapiKey,
67-
finalEthNetworknetwork,
68-
finalSupplier<IHttpExecutor>executorSupplier) {
69-
this(apiKey,network,executorSupplier,
70-
DEFAULT_KEY.equals(apiKey)
71-
?QueueManager.DEFAULT_KEY_QUEUE
72-
:newFakeQueueManager());
73-
}
74-
75-
publicEtherScanApi(finalStringapiKey,
76-
finalEthNetworknetwork,
77-
finalSupplier<IHttpExecutor>executorSupplier,
78-
finalIQueueManagerqueue) {
79-
if (BasicUtils.isBlank(apiKey))
80-
thrownewApiKeyException("API key can not be null or empty");
81-
82-
if (network ==null)
83-
thrownewApiException("Ethereum Network is set to NULL value");
84-
85-
// EtherScan 1request\5sec limit support by queue manager
86-
finalIHttpExecutorexecutor =executorSupplier.get();
87-
88-
finalStringending =EthNetwork.TOBALABA.equals(network) ?"com" :"io";
89-
finalStringbaseUrl ="https://" +network.getDomain() +".etherscan." +ending +"/api" +"?apikey=" +apiKey;
90-
91-
this.queueManager =queue;
92-
this.account =newAccountApiProvider(queue,baseUrl,executor);
93-
this.block =newBlockApiProvider(queue,baseUrl,executor);
94-
this.contract =newContractApiProvider(queue,baseUrl,executor);
95-
this.logs =newLogsApiProvider(queue,baseUrl,executor);
96-
this.proxy =newProxyApiProvider(queue,baseUrl,executor);
97-
this.stats =newStatisticApiProvider(queue,baseUrl,executor);
98-
this.txs =newTransactionApiProvider(queue,baseUrl,executor);
99-
}
100-
101-
@NotNull
102-
publicIAccountApiaccount() {
103-
returnaccount;
18+
super();
10419
}
10520

106-
@NotNull
107-
publicIContractApicontract() {
108-
returncontract;
21+
publicEtherScanApi(EthNetworknetwork) {
22+
super(network);
10923
}
11024

111-
@NotNull
112-
publicITransactionApitxs() {
113-
returntxs;
25+
publicEtherScanApi(StringapiKey) {
26+
super(apiKey);
11427
}
11528

116-
@NotNull
117-
publicIBlockApiblock() {
118-
returnblock;
29+
publicEtherScanApi(EthNetworknetwork,Supplier<IHttpExecutor>executorSupplier) {
30+
super(network,executorSupplier);
11931
}
12032

121-
@NotNull
122-
publicILogsApilogs() {
123-
returnlogs;
33+
publicEtherScanApi(StringapiKey,EthNetworknetwork,IQueueManagerqueue) {
34+
super(apiKey,network,queue);
12435
}
12536

126-
@NotNull
127-
publicIProxyApiproxy() {
128-
returnproxy;
37+
publicEtherScanApi(StringapiKey,EthNetworknetwork) {
38+
super(apiKey,network);
12939
}
13040

131-
@NotNull
132-
publicIStatisticApistats() {
133-
returnstats;
41+
publicEtherScanApi(StringapiKey,EthNetworknetwork,Supplier<IHttpExecutor>executorSupplier) {
42+
super(apiKey,network,executorSupplier);
13443
}
13544

136-
@Override
137-
publicvoidclose()throwsException {
138-
queueManager.close();
45+
publicEtherScanApi(StringapiKey,EthNetworknetwork,Supplier<IHttpExecutor>executorSupplier,IQueueManagerqueue) {
46+
super(apiKey,network,executorSupplier,queue);
13947
}
14048
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
packageio.api.etherscan.core.impl;
2+
3+
importio.api.etherscan.executor.IHttpExecutor;
4+
importio.api.etherscan.manager.IQueueManager;
5+
importio.api.etherscan.model.network.PolygonNetwork;
6+
7+
importjava.util.function.Supplier;
8+
9+
publicclassPolygonScanApiextendsBaseApi {
10+
11+
publicPolygonScanApi() {
12+
super(PolygonNetwork.MAINNET);
13+
}
14+
15+
publicPolygonScanApi(PolygonNetworknetwork) {
16+
super(network);
17+
}
18+
19+
publicPolygonScanApi(StringapiKey) {
20+
super(apiKey,PolygonNetwork.MAINNET);
21+
}
22+
23+
publicPolygonScanApi(PolygonNetworknetwork,Supplier<IHttpExecutor>executorSupplier) {
24+
super(network,executorSupplier);
25+
}
26+
27+
publicPolygonScanApi(StringapiKey,PolygonNetworknetwork,IQueueManagerqueue) {
28+
super(apiKey,network,queue);
29+
}
30+
31+
publicPolygonScanApi(StringapiKey,PolygonNetworknetwork) {
32+
super(apiKey,network);
33+
}
34+
35+
publicPolygonScanApi(StringapiKey,PolygonNetworknetwork,Supplier<IHttpExecutor>executorSupplier) {
36+
super(apiKey,network,executorSupplier);
37+
}
38+
39+
publicPolygonScanApi(StringapiKey,PolygonNetworknetwork,Supplier<IHttpExecutor>executorSupplier,IQueueManagerqueue) {
40+
super(apiKey,network,executorSupplier,queue);
41+
}
42+
}
Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,42 @@
11
packageio.api.etherscan.model;
22

3+
importio.api.etherscan.model.network.Network;
4+
35
/**
46
* ! NO DESCRIPTION !
57
*
68
* @author GoodforGod
79
* @since 28.10.2018
810
*/
9-
publicenumEthNetwork {
11+
publicenumEthNetworkimplementsNetwork{
1012

11-
MAINNET("api"),
12-
ROPSTEN("api-ropsten"),
13-
KOVAN("api-kovan"),
14-
TOBALABA("api-tobalaba"),
15-
GORLI("api-goerli"),
16-
RINKEBY("api-rinkeby");
13+
MAINNET("api","io"),
14+
ROPSTEN("api-ropsten","io"),
15+
KOVAN("api-kovan","io"),
16+
TOBALABA("api-tobalaba","com"),
17+
GORLI("api-goerli","io"),
18+
RINKEBY("api-rinkeby","io");
1719

1820
privatefinalStringdomain;
21+
privatefinalStringending;
1922

20-
EthNetwork(Stringdomain) {
23+
EthNetwork(Stringdomain,Stringending) {
2124
this.domain =domain;
25+
this.ending =ending;
2226
}
2327

28+
@Override
2429
publicStringgetDomain() {
2530
returndomain;
2631
}
32+
33+
@Override
34+
publicStringgetExplorerName() {
35+
return"etherscan";
36+
}
37+
38+
@Override
39+
publicStringgetEnding() {
40+
returnending;
41+
}
2742
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
packageio.api.etherscan.model.network;
2+
3+
publicinterfaceNetwork {
4+
5+
StringgetDomain();
6+
7+
StringgetExplorerName();
8+
9+
StringgetEnding();
10+
11+
defaultStringgetUrl() {
12+
return"https://" +getDomain() +"." +getExplorerName() +"." +getEnding() +"/api?apikey=";
13+
}
14+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp