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

Commite026400

Browse files
authored
Merge pull requestGoodforGod#2 from GoodforGod/develop
1.0.2 Release
2 parents97197ad +44a5fe4 commite026400

File tree

13 files changed

+56
-120
lines changed

13 files changed

+56
-120
lines changed

‎README.md‎

Lines changed: 4 additions & 2 deletions
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.1</version>
17+
<version>1.0.2</version>
1818
</dependency>
1919
```
2020

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

@@ -165,6 +165,8 @@ Token API methods migrated to [Account](#account-api) & [Stats](#stats-api) resp
165165

166166
##Version History
167167

168+
**1.0.2** - Minor http client improvements.
169+
168170
**1.0.1** - Gorli & TOBALABA networks support.
169171

170172
**1.0.0** - Initial project with all API functionality, for all available networks, with tests coverage for all cases.

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
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.1</version>
8+
<version>1.0.2</version>
99
<packaging>jar</packaging>
1010

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

‎src/main/java/io/api/etherscan/executor/impl/HttpExecutor.java‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
importio.api.etherscan.util.BasicUtils;
77

88
importjava.io.BufferedReader;
9-
importjava.io.DataOutputStream;
109
importjava.io.IOException;
1110
importjava.io.InputStreamReader;
11+
importjava.io.OutputStream;
1212
importjava.net.HttpURLConnection;
1313
importjava.net.SocketTimeoutException;
1414
importjava.net.URL;
15+
importjava.nio.charset.StandardCharsets;
1516
importjava.util.HashMap;
1617
importjava.util.Map;
1718
importjava.util.zip.GZIPInputStream;
@@ -103,14 +104,16 @@ public String get(final String urlAsString) {
103104
publicStringpost(finalStringurlAsString,finalStringdataToPost) {
104105
try {
105106
finalHttpURLConnectionconnection =buildConnection(urlAsString,"POST");
106-
finalStringcontentLength = (BasicUtils.isEmpty(dataToPost)) ?"0" :String.valueOf(dataToPost.length());
107-
connection.setRequestProperty("content-length",contentLength);
107+
finalStringcontentLength = (BasicUtils.isBlank(dataToPost)) ?"0" :String.valueOf(dataToPost.length());
108+
connection.setRequestProperty("Content-Type","application/json; charset=UTF-8");
109+
connection.setRequestProperty("Content-Length",contentLength);
110+
connection.setFixedLengthStreamingMode(dataToPost.length());
108111

109112
connection.setDoOutput(true);
110-
DataOutputStreamwr =newDataOutputStream(connection.getOutputStream());
111-
wr.writeBytes(dataToPost);
112-
wr.flush();
113-
wr.close();
113+
connection.connect();
114+
try (OutputStreamos =connection.getOutputStream()) {
115+
os.write(dataToPost.getBytes(StandardCharsets.UTF_8));
116+
}
114117

115118
finalintstatus =connection.getResponseCode();
116119
if (status ==HTTP_MOVED_TEMP ||status ==HTTP_MOVED_PERM) {
@@ -141,13 +144,13 @@ private String readData(final HttpURLConnection connection) throws IOException {
141144
}
142145

143146
privateInputStreamReadergetStreamReader(finalHttpURLConnectionconnection)throwsIOException {
144-
finalbooleanhaveEncoding =connection.getContentEncoding() !=null;
145-
146-
if (haveEncoding &&"gzip".equals(connection.getContentEncoding()))
147-
returnnewInputStreamReader(newGZIPInputStream(connection.getInputStream()),"utf-8");
148-
elseif (haveEncoding &&"deflate".equals(connection.getContentEncoding()))
149-
returnnewInputStreamReader(newInflaterInputStream(connection.getInputStream()),"utf-8");
150-
else
151-
returnnewInputStreamReader(connection.getInputStream(),"utf-8");
147+
switch (String.valueOf(connection.getContentEncoding())) {
148+
case"gzip":
149+
returnnewInputStreamReader(newGZIPInputStream(connection.getInputStream()),"utf-8");
150+
case"deflate":
151+
returnnewInputStreamReader(newInflaterInputStream(connection.getInputStream()),"utf-8");
152+
default:
153+
returnnewInputStreamReader(connection.getInputStream(),"utf-8");
154+
}
152155
}
153156
}

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,37 +73,26 @@ public BigInteger getGasUsed() {
7373
@Override
7474
publicbooleanequals(Objecto) {
7575
if (this ==o)returntrue;
76-
if (o ==null ||getClass() !=o.getClass())returnfalse;
76+
if (!(oinstanceofBaseTx))returnfalse;
7777

7878
BaseTxbaseTx = (BaseTx)o;
7979

8080
if (blockNumber !=baseTx.blockNumber)returnfalse;
8181
if (timeStamp !=null ? !timeStamp.equals(baseTx.timeStamp) :baseTx.timeStamp !=null)returnfalse;
82-
if (_timeStamp !=null ? !_timeStamp.equals(baseTx._timeStamp) :baseTx._timeStamp !=null)returnfalse;
8382
if (hash !=null ? !hash.equals(baseTx.hash) :baseTx.hash !=null)returnfalse;
8483
if (from !=null ? !from.equals(baseTx.from) :baseTx.from !=null)returnfalse;
8584
if (to !=null ? !to.equals(baseTx.to) :baseTx.to !=null)returnfalse;
86-
if (value !=null ? !value.equals(baseTx.value) :baseTx.value !=null)returnfalse;
87-
if (contractAddress !=null ? !contractAddress.equals(baseTx.contractAddress) :baseTx.contractAddress !=null)
88-
returnfalse;
89-
if (input !=null ? !input.equals(baseTx.input) :baseTx.input !=null)returnfalse;
90-
if (gas !=null ? !gas.equals(baseTx.gas) :baseTx.gas !=null)returnfalse;
91-
returngasUsed !=null ?gasUsed.equals(baseTx.gasUsed) :baseTx.gasUsed ==null;
85+
returnvalue !=null ?value.equals(baseTx.value) :baseTx.value ==null;
9286
}
9387

9488
@Override
9589
publicinthashCode() {
9690
intresult = (int) (blockNumber ^ (blockNumber >>>32));
9791
result =31 *result + (timeStamp !=null ?timeStamp.hashCode() :0);
98-
result =31 *result + (_timeStamp !=null ?_timeStamp.hashCode() :0);
9992
result =31 *result + (hash !=null ?hash.hashCode() :0);
10093
result =31 *result + (from !=null ?from.hashCode() :0);
10194
result =31 *result + (to !=null ?to.hashCode() :0);
10295
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);
10796
returnresult;
10897
}
10998

@@ -112,7 +101,6 @@ public String toString() {
112101
return"BaseTx{" +
113102
"blockNumber=" +blockNumber +
114103
", timeStamp='" +timeStamp +'\'' +
115-
", _timeStamp=" +_timeStamp +
116104
", hash='" +hash +'\'' +
117105
", from='" +from +'\'' +
118106
", to='" +to +'\'' +

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -106,44 +106,20 @@ public boolean equals(Object o) {
106106
Loglog = (Log)o;
107107

108108
if (blockNumber !=null ? !blockNumber.equals(log.blockNumber) :log.blockNumber !=null)returnfalse;
109-
if (_blockNumber !=null ? !_blockNumber.equals(log._blockNumber) :log._blockNumber !=null)returnfalse;
110109
if (address !=null ? !address.equals(log.address) :log.address !=null)returnfalse;
111110
if (transactionHash !=null ? !transactionHash.equals(log.transactionHash) :log.transactionHash !=null)
112111
returnfalse;
113-
if (transactionIndex !=null ? !transactionIndex.equals(log.transactionIndex) :log.transactionIndex !=null)
114-
returnfalse;
115-
if (_transactionIndex !=null ? !_transactionIndex.equals(log._transactionIndex) :log._transactionIndex !=null)
116-
returnfalse;
117112
if (timeStamp !=null ? !timeStamp.equals(log.timeStamp) :log.timeStamp !=null)returnfalse;
118-
if (_timeStamp !=null ? !_timeStamp.equals(log._timeStamp) :log._timeStamp !=null)returnfalse;
119-
if (data !=null ? !data.equals(log.data) :log.data !=null)returnfalse;
120-
if (gasPrice !=null ? !gasPrice.equals(log.gasPrice) :log.gasPrice !=null)returnfalse;
121-
if (_gasPrice !=null ? !_gasPrice.equals(log._gasPrice) :log._gasPrice !=null)returnfalse;
122-
if (gasUsed !=null ? !gasUsed.equals(log.gasUsed) :log.gasUsed !=null)returnfalse;
123-
if (_gasUsed !=null ? !_gasUsed.equals(log._gasUsed) :log._gasUsed !=null)returnfalse;
124-
if (topics !=null ? !topics.equals(log.topics) :log.topics !=null)returnfalse;
125-
if (logIndex !=null ? !logIndex.equals(log.logIndex) :log.logIndex !=null)returnfalse;
126-
return_logIndex !=null ?_logIndex.equals(log._logIndex) :log._logIndex ==null;
113+
returnlogIndex !=null ?logIndex.equals(log.logIndex) :log.logIndex ==null;
127114
}
128115

129116
@Override
130117
publicinthashCode() {
131118
intresult =blockNumber !=null ?blockNumber.hashCode() :0;
132-
result =31 *result + (_blockNumber !=null ?_blockNumber.hashCode() :0);
133119
result =31 *result + (address !=null ?address.hashCode() :0);
134120
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);
137121
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);
145122
result =31 *result + (logIndex !=null ?logIndex.hashCode() :0);
146-
result =31 *result + (_logIndex !=null ?_logIndex.hashCode() :0);
147123
returnresult;
148124
}
149125

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ public boolean equals(Object o) {
4949
if (Double.compare(price.ethbtc,ethbtc) !=0)returnfalse;
5050
if (ethusd_timestamp !=null ? !ethusd_timestamp.equals(price.ethusd_timestamp) :price.ethusd_timestamp !=null)
5151
returnfalse;
52-
if (ethbtc_timestamp !=null ? !ethbtc_timestamp.equals(price.ethbtc_timestamp) :price.ethbtc_timestamp !=null)
53-
returnfalse;
54-
if (_ethusd_timestamp !=null ? !_ethusd_timestamp.equals(price._ethusd_timestamp) :price._ethusd_timestamp !=null)
55-
returnfalse;
56-
return_ethbtc_timestamp !=null ?_ethbtc_timestamp.equals(price._ethbtc_timestamp) :price._ethbtc_timestamp ==null;
52+
return (ethbtc_timestamp !=null ? !ethbtc_timestamp.equals(price.ethbtc_timestamp) :price.ethbtc_timestamp !=null);
5753
}
5854

5955
@Override
@@ -66,8 +62,6 @@ public int hashCode() {
6662
result =31 *result + (int) (temp ^ (temp >>>32));
6763
result =31 *result + (ethusd_timestamp !=null ?ethusd_timestamp.hashCode() :0);
6864
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);
7165
returnresult;
7266
}
7367

@@ -78,8 +72,6 @@ public String toString() {
7872
", ethbtc=" +ethbtc +
7973
", ethusd_timestamp='" +ethusd_timestamp +'\'' +
8074
", ethbtc_timestamp='" +ethbtc_timestamp +'\'' +
81-
", _ethusd_timestamp=" +_ethusd_timestamp +
82-
", _ethbtc_timestamp=" +_ethbtc_timestamp +
8375
'}';
8476
}
8577
}

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,8 @@ public boolean equals(Object o) {
6565

6666
if (nonce !=tx.nonce)returnfalse;
6767
if (transactionIndex !=tx.transactionIndex)returnfalse;
68-
if (confirmations !=tx.confirmations)returnfalse;
6968
if (blockHash !=null ? !blockHash.equals(tx.blockHash) :tx.blockHash !=null)returnfalse;
70-
if (gasPrice !=null ? !gasPrice.equals(tx.gasPrice) :tx.gasPrice !=null)returnfalse;
71-
if (cumulativeGasUsed !=null ? !cumulativeGasUsed.equals(tx.cumulativeGasUsed) :tx.cumulativeGasUsed !=null)
72-
returnfalse;
73-
if (isError !=null ? !isError.equals(tx.isError) :tx.isError !=null)returnfalse;
74-
returntxreceipt_status !=null ?txreceipt_status.equals(tx.txreceipt_status) :tx.txreceipt_status ==null;
69+
returnisError !=null ?isError.equals(tx.isError) :tx.isError ==null;
7570
}
7671

7772
@Override
@@ -80,11 +75,7 @@ public int hashCode() {
8075
result =31 *result + (int) (nonce ^ (nonce >>>32));
8176
result =31 *result + (blockHash !=null ?blockHash.hashCode() :0);
8277
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));
8678
result =31 *result + (isError !=null ?isError.hashCode() :0);
87-
result =31 *result + (txreceipt_status !=null ?txreceipt_status.hashCode() :0);
8879
returnresult;
8980
}
9081

@@ -99,6 +90,6 @@ public String toString() {
9990
", confirmations=" +confirmations +
10091
", isError='" +isError +'\'' +
10192
", txreceipt_status='" +txreceipt_status +'\'' +
102-
'}';
93+
"} " +super.toString();
10394
}
10495
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,19 @@ public String getErrCode() {
3434
@Override
3535
publicbooleanequals(Objecto) {
3636
if (this ==o)returntrue;
37-
if (o ==null ||getClass() !=o.getClass())returnfalse;
37+
if (!(oinstanceofTxInternal))returnfalse;
3838
if (!super.equals(o))returnfalse;
3939

4040
TxInternalthat = (TxInternal)o;
4141

4242
if (traceId !=that.traceId)returnfalse;
43-
if (isError !=that.isError)returnfalse;
44-
if (type !=null ? !type.equals(that.type) :that.type !=null)returnfalse;
4543
returnerrCode !=null ?errCode.equals(that.errCode) :that.errCode ==null;
4644
}
4745

4846
@Override
4947
publicinthashCode() {
5048
intresult =super.hashCode();
51-
result =31 *result + (type !=null ?type.hashCode() :0);
5249
result =31 *result + (int) (traceId ^ (traceId >>>32));
53-
result =31 *result +isError;
5450
result =31 *result + (errCode !=null ?errCode.hashCode() :0);
5551
returnresult;
5652
}
@@ -62,6 +58,6 @@ public String toString() {
6258
", traceId=" +traceId +
6359
", isError=" +isError +
6460
", errCode='" +errCode +'\'' +
65-
'}';
61+
"} " +super.toString();
6662
}
6763
}

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

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -56,40 +56,6 @@ public long getConfirmations() {
5656
}
5757
//</editor-fold>
5858

59-
@Override
60-
publicbooleanequals(Objecto) {
61-
if (this ==o)returntrue;
62-
if (o ==null ||getClass() !=o.getClass())returnfalse;
63-
if (!super.equals(o))returnfalse;
64-
65-
TxTokentxToken = (TxToken)o;
66-
67-
if (nonce !=txToken.nonce)returnfalse;
68-
if (transactionIndex !=txToken.transactionIndex)returnfalse;
69-
if (gasPrice !=txToken.gasPrice)returnfalse;
70-
if (cumulativeGasUsed !=txToken.cumulativeGasUsed)returnfalse;
71-
if (confirmations !=txToken.confirmations)returnfalse;
72-
if (blockHash !=null ? !blockHash.equals(txToken.blockHash) :txToken.blockHash !=null)returnfalse;
73-
if (tokenName !=null ? !tokenName.equals(txToken.tokenName) :txToken.tokenName !=null)returnfalse;
74-
if (tokenSymbol !=null ? !tokenSymbol.equals(txToken.tokenSymbol) :txToken.tokenSymbol !=null)returnfalse;
75-
returntokenDecimal !=null ?tokenDecimal.equals(txToken.tokenDecimal) :txToken.tokenDecimal ==null;
76-
}
77-
78-
@Override
79-
publicinthashCode() {
80-
intresult =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-
returnresult;
91-
}
92-
9359
@Override
9460
publicStringtoString() {
9561
return"TxToken{" +
@@ -102,6 +68,6 @@ public String toString() {
10268
", gasPrice=" +gasPrice +
10369
", cumulativeGasUsed=" +cumulativeGasUsed +
10470
", confirmations=" +confirmations +
105-
'}';
71+
"} " +super.toString();
10672
}
10773
}

‎src/test/java/io/api/etherscan/account/AccountTxTokenTest.java‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,21 @@ public class AccountTxTokenTest extends Assert {
2020

2121
@Test
2222
publicvoidcorrect() {
23-
List<TxToken>txs =api.account().txsToken("0x05fBf1E3f105df6a4553f3C7f2ed93070A4BAB46");
23+
List<TxToken>txs =api.account().txsToken("0xE376F69ED2218076682e2b3B7b9099eC50aD68c4");
2424
assertNotNull(txs);
25-
assertEquals(106,txs.size());
25+
assertEquals(3,txs.size());
2626
assertTxs(txs);
2727
assertNotEquals(0,txs.get(0).getGasPrice());
2828
assertNotEquals(-1,txs.get(0).getNonce());
29+
2930
assertNotNull(txs.get(0).toString());
31+
assertNotEquals(txs.get(0).toString(),txs.get(1).toString());
32+
3033
assertNotEquals(txs.get(0),txs.get(1));
3134
assertNotEquals(txs.get(0).hashCode(),txs.get(1).hashCode());
35+
36+
assertEquals(txs.get(1),txs.get(1));
37+
assertEquals(txs.get(1).hashCode(),txs.get(1).hashCode());
3238
}
3339

3440
@Test

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp