Skip to content

Commit cafcdff

Browse files
authored
Merge pull request GoodforGod#19 from GoodforGod/dev
[1.2.1]
2 parents 22c9679 + aae1546 commit cafcdff

File tree

16 files changed

+59
-15
lines changed

16 files changed

+59
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Library supports all available EtherScan *API* calls for all available *Ethereum
1515
**Gradle**
1616
```groovy
1717
dependencies {
18-
compile "com.github.goodforgod:java-etherscan-api:1.2.0"
18+
compile "com.github.goodforgod:java-etherscan-api:1.2.1"
1919
}
2020
```
2121

@@ -24,7 +24,7 @@ dependencies {
2424
<dependency>
2525
<groupId>com.github.goodforgod</groupId>
2626
<artifactId>java-etherscan-api</artifactId>
27-
<version>1.2.0</version>
27+
<version>1.2.1</version>
2828
</dependency>
2929
```
3030

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies {
3838
implementation "org.jetbrains:annotations:22.0.0"
3939
implementation "com.google.code.gson:gson:2.8.9"
4040

41-
testImplementation "junit:junit:4.13.1"
41+
testImplementation "junit:junit:4.13.2"
4242
}
4343

4444
test {

gradle.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
groupId=com.github.goodforgod
22
artifactId=java-etherscan-api
3-
artifactVersion=1.2.0
4-
buildNumber=1
3+
artifactVersion=1.2.1
54

65

76
##### GRADLE #####
87
org.gradle.daemon=true
98
org.gradle.parallel=true
109
org.gradle.configureondemand=true
1110
org.gradle.caching=true
12-
org.gradle.jvmargs=-Dfile.encoding=UTF-8
11+
org.gradle.jvmargs=-Dfile.encoding=UTF-8

src/main/java/io/api/etherscan/core/IProxyApi.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.api.etherscan.model.proxy.BlockProxy;
55
import io.api.etherscan.model.proxy.ReceiptProxy;
66
import io.api.etherscan.model.proxy.TxProxy;
7+
import org.jetbrains.annotations.ApiStatus.Experimental;
78
import org.jetbrains.annotations.NotNull;
89

910
import java.math.BigInteger;
@@ -139,6 +140,7 @@ public interface IProxyApi {
139140
* @return optional the value at this storage position
140141
* @throws ApiException parent exception class
141142
*/
143+
@Experimental
142144
@NotNull
143145
Optional<String> storageAt(String address, long position) throws ApiException;
144146

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.api.etherscan.core.impl;
22

3-
import com.google.gson.Gson;
3+
import com.google.gson.*;
44
import io.api.etherscan.error.ApiException;
55
import io.api.etherscan.error.EtherScanException;
66
import io.api.etherscan.error.ParseException;
@@ -10,6 +10,8 @@
1010
import io.api.etherscan.model.utility.StringResponseTO;
1111
import io.api.etherscan.util.BasicUtils;
1212

13+
import java.time.LocalDate;
14+
import java.time.LocalDateTime;
1315
import java.util.Map;
1416

1517
/**
@@ -40,7 +42,12 @@ abstract class BasicProvider {
4042
this.module = "&module=" + module;
4143
this.baseUrl = baseUrl;
4244
this.executor = executor;
43-
this.gson = new Gson();
45+
this.gson = new GsonBuilder()
46+
.registerTypeAdapter(LocalDateTime.class, (JsonSerializer<LocalDateTime>) (src, t, c) -> new JsonPrimitive(""))
47+
.registerTypeAdapter(LocalDate.class, (JsonSerializer<LocalDate>) (src, t, context) -> new JsonPrimitive(""))
48+
.registerTypeAdapter(LocalDateTime.class, (JsonDeserializer<LocalDateTime>) (json, t, c) -> null)
49+
.registerTypeAdapter(LocalDate.class, (JsonDeserializer<LocalDate>) (json, t, c) -> null)
50+
.create();
4451
}
4552

4653
<T> T convert(final String json, final Class<T> tClass) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.api.etherscan.model;
22

3+
import com.google.gson.annotations.Expose;
34
import io.api.etherscan.util.BasicUtils;
45

56
import java.math.BigInteger;
@@ -17,6 +18,7 @@ abstract class BaseTx {
1718

1819
private long blockNumber;
1920
private String timeStamp;
21+
@Expose(serialize = false, deserialize = false)
2022
private LocalDateTime _timeStamp;
2123
private String hash;
2224
private String from;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.api.etherscan.model;
22

3+
import com.google.gson.annotations.Expose;
34
import io.api.etherscan.util.BasicUtils;
45

56
import java.math.BigInteger;
@@ -17,6 +18,7 @@ public class Block {
1718
private long blockNumber;
1819
private BigInteger blockReward;
1920
private String timeStamp;
21+
@Expose(serialize = false, deserialize = false)
2022
private LocalDateTime _timeStamp;
2123

2224
// <editor-fold desc="Getter">

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.api.etherscan.model;
22

3+
import com.google.gson.annotations.Expose;
34
import io.api.etherscan.util.BasicUtils;
45

56
import java.math.BigInteger;
@@ -17,20 +18,26 @@
1718
public class Log {
1819

1920
private String blockNumber;
21+
@Expose(serialize = false, deserialize = false)
2022
private Long _blockNumber;
2123
private String address;
2224
private String transactionHash;
2325
private String transactionIndex;
26+
@Expose(serialize = false, deserialize = false)
2427
private Long _transactionIndex;
2528
private String timeStamp;
29+
@Expose(serialize = false, deserialize = false)
2630
private LocalDateTime _timeStamp;
2731
private String data;
2832
private String gasPrice;
33+
@Expose(serialize = false, deserialize = false)
2934
private BigInteger _gasPrice;
3035
private String gasUsed;
36+
@Expose(serialize = false, deserialize = false)
3137
private BigInteger _gasUsed;
3238
private List<String> topics;
3339
private String logIndex;
40+
@Expose(serialize = false, deserialize = false)
3441
private Long _logIndex;
3542

3643
// <editor-fold desc="Getters">

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.api.etherscan.model;
22

3+
import com.google.gson.annotations.Expose;
4+
35
import java.time.LocalDateTime;
46
import java.time.ZoneOffset;
57

@@ -15,7 +17,9 @@ public class Price {
1517
private double ethbtc;
1618
private String ethusd_timestamp;
1719
private String ethbtc_timestamp;
20+
@Expose(serialize = false, deserialize = false)
1821
private LocalDateTime _ethusd_timestamp;
22+
@Expose(serialize = false, deserialize = false)
1923
private LocalDateTime _ethbtc_timestamp;
2024

2125
public double inUsd() {

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class TxInternal extends BaseTx {
1212

1313
private String type;
14-
private long traceId;
14+
private String traceId;
1515
private int isError;
1616
private String errCode;
1717

@@ -21,6 +21,10 @@ public String getType() {
2121
}
2222

2323
public long getTraceId() {
24+
return (traceId == null) ? 0 : Long.parseLong(traceId);
25+
}
26+
27+
public String getTraceIdAsString() {
2428
return traceId;
2529
}
2630

@@ -44,15 +48,15 @@ public boolean equals(Object o) {
4448

4549
TxInternal that = (TxInternal) o;
4650

47-
if (traceId != that.traceId)
51+
if (!Objects.equals(traceId, that.traceId))
4852
return false;
4953
return Objects.equals(errCode, that.errCode);
5054
}
5155

5256
@Override
5357
public int hashCode() {
5458
int result = super.hashCode();
55-
result = 31 * result + (int) (traceId ^ (traceId >>> 32));
59+
result = 31 * result + (traceId != null ? traceId.hashCode() : 0);
5660
result = 31 * result + (errCode != null ? errCode.hashCode() : 0);
5761
return result;
5862
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy