Skip to content

Commit

Permalink
Fix No virtual method longValueExact() on devices running Android 11 …
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrouR authored Sep 29, 2021
1 parent 5e237d9 commit 35724dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/web3j/ens/EnsResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ boolean isSynced() throws Exception {
} else {
EthBlock ethBlock =
web3j.ethGetBlockByNumber(DefaultBlockParameterName.LATEST, false).send();
long timestamp = ethBlock.getBlock().getTimestamp().longValueExact() * 1000;
long timestamp = ethBlock.getBlock().getTimestamp().longValue() * 1000;

return System.currentTimeMillis() - syncThreshold < timestamp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,19 @@ public long getV() {
// https://github.com/ethereum/go-ethereum/issues/3339
public void setV(Object v) {
if (v instanceof String) {
this.v = Numeric.toBigInt((String) v).longValueExact();
// longValueExact() is not implemented on android 11 or later only on 12 so it was
// replaced with longValue.
this.v = Numeric.toBigInt((String) v).longValue();
} else if (v instanceof Integer) {
this.v = ((Integer) v).longValue();
} else {
this.v = (Long) v;
}
}

// public void setV(byte v) {
// this.v = v;
// }
// public void setV(byte v) {
// this.v = v;
// }

public Long getChainId() {
if (v == LOWER_REAL_V || v == (LOWER_REAL_V + 1)) {
Expand Down

0 comments on commit 35724dc

Please sign in to comment.