Skip to content

Commit 76fe479

Browse files
committed
Gorli & TOBALABA networks support
1.0.1 release
1 parent 4cd9af6 commit 76fe479

16 files changed

+276
-13
lines changed

README.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ Library supports all available EtherScan *API* calls for all available *Ethereum
1414
<dependency>
1515
<groupId>com.github.goodforgod</groupId>
1616
<artifactId>java-etherscan-api</artifactId>
17-
<version>1.0.0</version>
17+
<version>1.0.1</version>
1818
</dependency>
1919
```
2020

2121
**Gradle**
2222
```groovy
2323
dependencies {
24-
compile 'com.github.goodforgod:java-etherscan-api:1.0.0'
24+
compile 'com.github.goodforgod:java-etherscan-api:1.0.1'
2525
}
2626
```
2727

@@ -40,8 +40,12 @@ dependencies {
4040
- [Version History](#version-history)
4141

4242
## Mainnet and Testnets
43-
API support Ethereum: *[MAINNET](https://etherscan.io), [ROPSTEN](https://ropsten.etherscan.io),
44-
[KOVAN](https://kovan.etherscan.io), [RINKEBY](https://rinkeby.etherscan.io)* networks.
43+
API support Ethereum: *[MAINNET](https://etherscan.io),
44+
[ROPSTEN](https://ropsten.etherscan.io),
45+
[KOVAN](https://kovan.etherscan.io),
46+
[RINKEBY](https://rinkeby.etherscan.io),
47+
[GORLI](https://goerli.etherscan.io),
48+
[TOBALABA](https://tobalaba.etherscan.com)* networks.
4549
```java
4650
EtherScanApi api = new EtherScanApi(EthNetwork.MAINNET); // Default
4751
EtherScanApi apiRinkeby = new EtherScanApi(EthNetwork.RINKEBY);
@@ -161,6 +165,8 @@ Token API methods migrated to [Account](#account-api) & [Stats](#stats-api) resp
161165

162166
## Version History
163167

168+
**1.0.1** - Gorli & TOBALABA networks support.
169+
164170
**1.0.0** - Initial project with all API functionality, for all available networks, with tests coverage for all cases.
165171

166172
## License

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.goodforgod</groupId>
77
<artifactId>java-etherscan-api</artifactId>
8-
<version>1.0.0</version>
8+
<version>1.0.1</version>
99
<packaging>jar</packaging>
1010

1111
<name>${project.groupId}:${project.artifactId}</name>

src/main/java/io/api/etherscan/core/impl/EtherScanApi.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ public EtherScanApi(final String apiKey,
7070
: new QueueManager(5, 1);
7171

7272
final IHttpExecutor executor = executorSupplier.get();
73-
final String baseUrl = "https://" + network.getDomain() + ".etherscan.io/api" + "?apikey=" + apiKey;
73+
74+
final String ending = (EthNetwork.TOBALABA.equals(network)) ? "com" : "io";
75+
final String baseUrl = "https://" + network.getDomain() + ".etherscan." + ending + "/api" + "?apikey=" + apiKey;
7476

7577
this.account = new AccountApiProvider(masterQueue, baseUrl, executor);
7678
this.block = new BlockApiProvider(masterQueue, baseUrl, executor);

src/main/java/io/api/etherscan/model/BaseTx.java

+24-2
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,34 @@ public boolean equals(Object o) {
7777

7878
BaseTx baseTx = (BaseTx) o;
7979

80-
return hash != null ? hash.equals(baseTx.hash) : baseTx.hash == null;
80+
if (blockNumber != baseTx.blockNumber) return false;
81+
if (timeStamp != null ? !timeStamp.equals(baseTx.timeStamp) : baseTx.timeStamp != null) return false;
82+
if (_timeStamp != null ? !_timeStamp.equals(baseTx._timeStamp) : baseTx._timeStamp != null) return false;
83+
if (hash != null ? !hash.equals(baseTx.hash) : baseTx.hash != null) return false;
84+
if (from != null ? !from.equals(baseTx.from) : baseTx.from != null) return false;
85+
if (to != null ? !to.equals(baseTx.to) : baseTx.to != null) return false;
86+
if (value != null ? !value.equals(baseTx.value) : baseTx.value != null) return false;
87+
if (contractAddress != null ? !contractAddress.equals(baseTx.contractAddress) : baseTx.contractAddress != null)
88+
return false;
89+
if (input != null ? !input.equals(baseTx.input) : baseTx.input != null) return false;
90+
if (gas != null ? !gas.equals(baseTx.gas) : baseTx.gas != null) return false;
91+
return gasUsed != null ? gasUsed.equals(baseTx.gasUsed) : baseTx.gasUsed == null;
8192
}
8293

8394
@Override
8495
public int hashCode() {
85-
return hash != null ? hash.hashCode() : 0;
96+
int result = (int) (blockNumber ^ (blockNumber >>> 32));
97+
result = 31 * result + (timeStamp != null ? timeStamp.hashCode() : 0);
98+
result = 31 * result + (_timeStamp != null ? _timeStamp.hashCode() : 0);
99+
result = 31 * result + (hash != null ? hash.hashCode() : 0);
100+
result = 31 * result + (from != null ? from.hashCode() : 0);
101+
result = 31 * result + (to != null ? to.hashCode() : 0);
102+
result = 31 * result + (value != null ? value.hashCode() : 0);
103+
result = 31 * result + (contractAddress != null ? contractAddress.hashCode() : 0);
104+
result = 31 * result + (input != null ? input.hashCode() : 0);
105+
result = 31 * result + (gas != null ? gas.hashCode() : 0);
106+
result = 31 * result + (gasUsed != null ? gasUsed.hashCode() : 0);
107+
return result;
86108
}
87109

88110
@Override

src/main/java/io/api/etherscan/model/EthNetwork.java

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public enum EthNetwork {
1010
MAINNET("api"),
1111
ROPSTEN("api-ropsten"),
1212
KOVAN("api-kovan"),
13+
TOBALABA("api-tobalaba"),
14+
GORLI("api-goerli"),
1315
RINKEBY("api-rinkeby");
1416

1517
private final String domain;

src/main/java/io/api/etherscan/model/Log.java

+49
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,55 @@ public Long getLogIndex() {
9898
}
9999
//</editor-fold>
100100

101+
@Override
102+
public boolean equals(Object o) {
103+
if (this == o) return true;
104+
if (o == null || getClass() != o.getClass()) return false;
105+
106+
Log log = (Log) o;
107+
108+
if (blockNumber != null ? !blockNumber.equals(log.blockNumber) : log.blockNumber != null) return false;
109+
if (_blockNumber != null ? !_blockNumber.equals(log._blockNumber) : log._blockNumber != null) return false;
110+
if (address != null ? !address.equals(log.address) : log.address != null) return false;
111+
if (transactionHash != null ? !transactionHash.equals(log.transactionHash) : log.transactionHash != null)
112+
return false;
113+
if (transactionIndex != null ? !transactionIndex.equals(log.transactionIndex) : log.transactionIndex != null)
114+
return false;
115+
if (_transactionIndex != null ? !_transactionIndex.equals(log._transactionIndex) : log._transactionIndex != null)
116+
return false;
117+
if (timeStamp != null ? !timeStamp.equals(log.timeStamp) : log.timeStamp != null) return false;
118+
if (_timeStamp != null ? !_timeStamp.equals(log._timeStamp) : log._timeStamp != null) return false;
119+
if (data != null ? !data.equals(log.data) : log.data != null) return false;
120+
if (gasPrice != null ? !gasPrice.equals(log.gasPrice) : log.gasPrice != null) return false;
121+
if (_gasPrice != null ? !_gasPrice.equals(log._gasPrice) : log._gasPrice != null) return false;
122+
if (gasUsed != null ? !gasUsed.equals(log.gasUsed) : log.gasUsed != null) return false;
123+
if (_gasUsed != null ? !_gasUsed.equals(log._gasUsed) : log._gasUsed != null) return false;
124+
if (topics != null ? !topics.equals(log.topics) : log.topics != null) return false;
125+
if (logIndex != null ? !logIndex.equals(log.logIndex) : log.logIndex != null) return false;
126+
return _logIndex != null ? _logIndex.equals(log._logIndex) : log._logIndex == null;
127+
}
128+
129+
@Override
130+
public int hashCode() {
131+
int result = blockNumber != null ? blockNumber.hashCode() : 0;
132+
result = 31 * result + (_blockNumber != null ? _blockNumber.hashCode() : 0);
133+
result = 31 * result + (address != null ? address.hashCode() : 0);
134+
result = 31 * result + (transactionHash != null ? transactionHash.hashCode() : 0);
135+
result = 31 * result + (transactionIndex != null ? transactionIndex.hashCode() : 0);
136+
result = 31 * result + (_transactionIndex != null ? _transactionIndex.hashCode() : 0);
137+
result = 31 * result + (timeStamp != null ? timeStamp.hashCode() : 0);
138+
result = 31 * result + (_timeStamp != null ? _timeStamp.hashCode() : 0);
139+
result = 31 * result + (data != null ? data.hashCode() : 0);
140+
result = 31 * result + (gasPrice != null ? gasPrice.hashCode() : 0);
141+
result = 31 * result + (_gasPrice != null ? _gasPrice.hashCode() : 0);
142+
result = 31 * result + (gasUsed != null ? gasUsed.hashCode() : 0);
143+
result = 31 * result + (_gasUsed != null ? _gasUsed.hashCode() : 0);
144+
result = 31 * result + (topics != null ? topics.hashCode() : 0);
145+
result = 31 * result + (logIndex != null ? logIndex.hashCode() : 0);
146+
result = 31 * result + (_logIndex != null ? _logIndex.hashCode() : 0);
147+
return result;
148+
}
149+
101150
@Override
102151
public String toString() {
103152
return "Log{" +

src/main/java/io/api/etherscan/model/Price.java

+33
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,39 @@ public LocalDateTime btcTimestamp() {
3838
return _ethbtc_timestamp;
3939
}
4040

41+
@Override
42+
public boolean equals(Object o) {
43+
if (this == o) return true;
44+
if (o == null || getClass() != o.getClass()) return false;
45+
46+
Price price = (Price) o;
47+
48+
if (Double.compare(price.ethusd, ethusd) != 0) return false;
49+
if (Double.compare(price.ethbtc, ethbtc) != 0) return false;
50+
if (ethusd_timestamp != null ? !ethusd_timestamp.equals(price.ethusd_timestamp) : price.ethusd_timestamp != null)
51+
return false;
52+
if (ethbtc_timestamp != null ? !ethbtc_timestamp.equals(price.ethbtc_timestamp) : price.ethbtc_timestamp != null)
53+
return false;
54+
if (_ethusd_timestamp != null ? !_ethusd_timestamp.equals(price._ethusd_timestamp) : price._ethusd_timestamp != null)
55+
return false;
56+
return _ethbtc_timestamp != null ? _ethbtc_timestamp.equals(price._ethbtc_timestamp) : price._ethbtc_timestamp == null;
57+
}
58+
59+
@Override
60+
public int hashCode() {
61+
int result;
62+
long temp;
63+
temp = Double.doubleToLongBits(ethusd);
64+
result = (int) (temp ^ (temp >>> 32));
65+
temp = Double.doubleToLongBits(ethbtc);
66+
result = 31 * result + (int) (temp ^ (temp >>> 32));
67+
result = 31 * result + (ethusd_timestamp != null ? ethusd_timestamp.hashCode() : 0);
68+
result = 31 * result + (ethbtc_timestamp != null ? ethbtc_timestamp.hashCode() : 0);
69+
result = 31 * result + (_ethusd_timestamp != null ? _ethusd_timestamp.hashCode() : 0);
70+
result = 31 * result + (_ethbtc_timestamp != null ? _ethbtc_timestamp.hashCode() : 0);
71+
return result;
72+
}
73+
4174
@Override
4275
public String toString() {
4376
return "Price{" +

src/main/java/io/api/etherscan/model/Status.java

+18
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ public String getErrDescription() {
2222
return errDescription;
2323
}
2424

25+
@Override
26+
public boolean equals(Object o) {
27+
if (this == o) return true;
28+
if (o == null || getClass() != o.getClass()) return false;
29+
30+
Status status = (Status) o;
31+
32+
if (isError != status.isError) return false;
33+
return errDescription != null ? errDescription.equals(status.errDescription) : status.errDescription == null;
34+
}
35+
36+
@Override
37+
public int hashCode() {
38+
int result = isError;
39+
result = 31 * result + (errDescription != null ? errDescription.hashCode() : 0);
40+
return result;
41+
}
42+
2543
@Override
2644
public String toString() {
2745
return "Status{" +

src/main/java/io/api/etherscan/model/Tx.java

+33
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,39 @@ public long getConfirmations() {
5555
}
5656
//</editor-fold>
5757

58+
@Override
59+
public boolean equals(Object o) {
60+
if (this == o) return true;
61+
if (o == null || getClass() != o.getClass()) return false;
62+
if (!super.equals(o)) return false;
63+
64+
Tx tx = (Tx) o;
65+
66+
if (nonce != tx.nonce) return false;
67+
if (transactionIndex != tx.transactionIndex) return false;
68+
if (confirmations != tx.confirmations) return false;
69+
if (blockHash != null ? !blockHash.equals(tx.blockHash) : tx.blockHash != null) return false;
70+
if (gasPrice != null ? !gasPrice.equals(tx.gasPrice) : tx.gasPrice != null) return false;
71+
if (cumulativeGasUsed != null ? !cumulativeGasUsed.equals(tx.cumulativeGasUsed) : tx.cumulativeGasUsed != null)
72+
return false;
73+
if (isError != null ? !isError.equals(tx.isError) : tx.isError != null) return false;
74+
return txreceipt_status != null ? txreceipt_status.equals(tx.txreceipt_status) : tx.txreceipt_status == null;
75+
}
76+
77+
@Override
78+
public int hashCode() {
79+
int result = super.hashCode();
80+
result = 31 * result + (int) (nonce ^ (nonce >>> 32));
81+
result = 31 * result + (blockHash != null ? blockHash.hashCode() : 0);
82+
result = 31 * result + transactionIndex;
83+
result = 31 * result + (gasPrice != null ? gasPrice.hashCode() : 0);
84+
result = 31 * result + (cumulativeGasUsed != null ? cumulativeGasUsed.hashCode() : 0);
85+
result = 31 * result + (int) (confirmations ^ (confirmations >>> 32));
86+
result = 31 * result + (isError != null ? isError.hashCode() : 0);
87+
result = 31 * result + (txreceipt_status != null ? txreceipt_status.hashCode() : 0);
88+
return result;
89+
}
90+
5891
@Override
5992
public String toString() {
6093
return "Tx{" +

src/main/java/io/api/etherscan/model/TxInternal.java

+24
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,30 @@ public String getErrCode() {
3131
}
3232
//</editor-fold>
3333

34+
@Override
35+
public boolean equals(Object o) {
36+
if (this == o) return true;
37+
if (o == null || getClass() != o.getClass()) return false;
38+
if (!super.equals(o)) return false;
39+
40+
TxInternal that = (TxInternal) o;
41+
42+
if (traceId != that.traceId) return false;
43+
if (isError != that.isError) return false;
44+
if (type != null ? !type.equals(that.type) : that.type != null) return false;
45+
return errCode != null ? errCode.equals(that.errCode) : that.errCode == null;
46+
}
47+
48+
@Override
49+
public int hashCode() {
50+
int result = super.hashCode();
51+
result = 31 * result + (type != null ? type.hashCode() : 0);
52+
result = 31 * result + (int) (traceId ^ (traceId >>> 32));
53+
result = 31 * result + isError;
54+
result = 31 * result + (errCode != null ? errCode.hashCode() : 0);
55+
return result;
56+
}
57+
3458
@Override
3559
public String toString() {
3660
return "TxInternal{" +

src/main/java/io/api/etherscan/model/TxToken.java

+34
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,40 @@ public long getConfirmations() {
5656
}
5757
//</editor-fold>
5858

59+
@Override
60+
public boolean equals(Object o) {
61+
if (this == o) return true;
62+
if (o == null || getClass() != o.getClass()) return false;
63+
if (!super.equals(o)) return false;
64+
65+
TxToken txToken = (TxToken) o;
66+
67+
if (nonce != txToken.nonce) return false;
68+
if (transactionIndex != txToken.transactionIndex) return false;
69+
if (gasPrice != txToken.gasPrice) return false;
70+
if (cumulativeGasUsed != txToken.cumulativeGasUsed) return false;
71+
if (confirmations != txToken.confirmations) return false;
72+
if (blockHash != null ? !blockHash.equals(txToken.blockHash) : txToken.blockHash != null) return false;
73+
if (tokenName != null ? !tokenName.equals(txToken.tokenName) : txToken.tokenName != null) return false;
74+
if (tokenSymbol != null ? !tokenSymbol.equals(txToken.tokenSymbol) : txToken.tokenSymbol != null) return false;
75+
return tokenDecimal != null ? tokenDecimal.equals(txToken.tokenDecimal) : txToken.tokenDecimal == null;
76+
}
77+
78+
@Override
79+
public int hashCode() {
80+
int result = super.hashCode();
81+
result = 31 * result + (int) (nonce ^ (nonce >>> 32));
82+
result = 31 * result + (blockHash != null ? blockHash.hashCode() : 0);
83+
result = 31 * result + (tokenName != null ? tokenName.hashCode() : 0);
84+
result = 31 * result + (tokenSymbol != null ? tokenSymbol.hashCode() : 0);
85+
result = 31 * result + (tokenDecimal != null ? tokenDecimal.hashCode() : 0);
86+
result = 31 * result + transactionIndex;
87+
result = 31 * result + (int) (gasPrice ^ (gasPrice >>> 32));
88+
result = 31 * result + (int) (cumulativeGasUsed ^ (cumulativeGasUsed >>> 32));
89+
result = 31 * result + (int) (confirmations ^ (confirmations >>> 32));
90+
return result;
91+
}
92+
5993
@Override
6094
public String toString() {
6195
return "TxToken{" +

src/main/java/io/api/etherscan/model/Uncle.java

+20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ public int getUnclePosition() {
2828
}
2929
//</editor-fold>
3030

31+
@Override
32+
public boolean equals(Object o) {
33+
if (this == o) return true;
34+
if (o == null || getClass() != o.getClass()) return false;
35+
36+
Uncle uncle = (Uncle) o;
37+
38+
if (unclePosition != uncle.unclePosition) return false;
39+
if (miner != null ? !miner.equals(uncle.miner) : uncle.miner != null) return false;
40+
return blockreward != null ? blockreward.equals(uncle.blockreward) : uncle.blockreward == null;
41+
}
42+
43+
@Override
44+
public int hashCode() {
45+
int result = miner != null ? miner.hashCode() : 0;
46+
result = 31 * result + (blockreward != null ? blockreward.hashCode() : 0);
47+
result = 31 * result + unclePosition;
48+
return result;
49+
}
50+
3151
@Override
3252
public String toString() {
3353
return "Uncle{" +

src/test/java/io/api/etherscan/EtherScanApiTest.java

+16
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ public void noTimeoutOnRead() {
5656
assertNotNull(balance);
5757
}
5858

59+
@Test
60+
public void noTimeoutOnReadGroli() {
61+
Supplier<IHttpExecutor> supplier = () -> new HttpExecutor(300);
62+
EtherScanApi api = new EtherScanApi(EthNetwork.GORLI, supplier);
63+
Balance balance = api.account().balance("0xF318ABc9A5a92357c4Fea8d082dade4D43e780B7");
64+
assertNotNull(balance);
65+
}
66+
67+
@Test
68+
public void noTimeoutOnReadTobalala() {
69+
Supplier<IHttpExecutor> supplier = () -> new HttpExecutor(30000);
70+
EtherScanApi api = new EtherScanApi(EthNetwork.TOBALABA, supplier);
71+
Balance balance = api.account().balance("0xF318ABc9A5a92357c4Fea8d082dade4D43e780B7");
72+
assertNotNull(balance);
73+
}
74+
5975
@Test
6076
public void noTimeoutUnlimitedAwait() {
6177
Supplier<IHttpExecutor> supplier = () -> new HttpExecutor(-30, -300);

0 commit comments

Comments
 (0)