Skip to content

Commit

Permalink
[hyperledger#2766]fix: clean up deprecation warnings (hyperledger#3511)
Browse files Browse the repository at this point in the history
* clean up deprecation warnings
*Quantity Interface getValue()
* LegacyPrivateStateStorage
* GraphQLDataFetcherContext

Signed-off-by: Sandra Wang <yx97.wang@gmail.com>

Co-authored-by: Sally MacFarlane <sally.macfarlane@consensys.net>
  • Loading branch information
2 people authored and garyschulte committed May 2, 2022
1 parent 6029756 commit c0f1dcc
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public String serialize() {
@Override
public boolean equals(final Object o) {
if (o instanceof PayloadIdentifier) {
return getValue().equals(((PayloadIdentifier) o).getValue());
return getAsBigInteger().equals(((PayloadIdentifier) o).getAsBigInteger());
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public void serializesToEvenHexRepresentation() {
public void conversionCoverage() {
var idTest = PayloadIdentifier.forPayloadParams(Hash.ZERO, 1337L);
assertThat(new PayloadIdentifier(idTest.getAsBigInteger().longValue())).isEqualTo(idTest);
assertThat(new PayloadIdentifier(idTest.getValue().longValue())).isEqualTo(idTest);
assertThat(new PayloadIdentifier(idTest.getAsBigInteger().longValue())).isEqualTo(idTest);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static com.google.errorprone.util.ASTHelpers.isSubtype;

import java.util.List;
import java.util.Optional;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier;

Expand All @@ -29,6 +30,7 @@
import com.google.errorprone.VisitorState;
import com.google.errorprone.bugpatterns.BugChecker;
import com.google.errorprone.bugpatterns.BugChecker.VariableTreeMatcher;
import com.google.errorprone.fixes.SuggestedFix;
import com.google.errorprone.matchers.Description;
import com.google.errorprone.suppliers.Supplier;
import com.google.errorprone.suppliers.Suppliers;
Expand Down Expand Up @@ -60,8 +62,10 @@ public Description matchVariable(final VariableTree tree, final VisitorState sta
if (!isSubtype(getType(tree), ORG_SLF4J_LOGGER.get(state), state)) {
return NO_MATCH;
}
Optional<SuggestedFix> fixes =
addModifiers(tree, state, Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL);
return buildDescription(tree)
.addFix(addModifiers(tree, state, Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL))
.addFix(fixes.isPresent() ? fixes.get() : SuggestedFix.emptyFix())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ private static BigInteger ensureMinimumDifficulty(final BigInteger difficulty) {
}

private static BigInteger difficulty(final Quantity value) {
return (BigInteger) value.getValue();
return value.getAsBigInteger();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ private static BigInteger ensureMinimumDifficulty(final BigInteger difficulty) {
}

private static BigInteger difficulty(final Quantity value) {
return (BigInteger) value.getValue();
return value.getAsBigInteger();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public BaseFeePendingTransactionsSorter(
.getMaxPriorityFeePerGas()
// safe to .get() here because only 1559 txs can be in the static range
.get()
.getValue()
.getAsBigInteger()
.longValue())
.thenComparing(TransactionInfo::getSequence)
.reversed());
Expand All @@ -97,7 +97,7 @@ public BaseFeePendingTransactionsSorter(
transactionInfo
.getTransaction()
.getMaxFeePerGas()
.map(maxFeePerGas -> maxFeePerGas.getValue().longValue())
.map(maxFeePerGas -> maxFeePerGas.getAsBigInteger().longValue())
.orElse(transactionInfo.getGasPrice().toLong()))
.thenComparing(TransactionInfo::getSequence)
.reversed());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ private long suggestGasPrice(final Block block) {
return block.getBody().getTransactions().stream()
.min(Comparator.comparing(t -> t.getEffectiveGasPrice(block.getHeader().getBaseFee())))
.map(t -> t.getEffectiveGasPrice(block.getHeader().getBaseFee()))
.filter(wei -> wei.getValue().longValue() > 0)
.filter(wei -> wei.getAsBigInteger().longValue() > 0)
.orElse(miningCoordinator.getMinTransactionGasPrice())
.getValue()
.getAsBigInteger()
.longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ protected Call createRequest(final StreamRequestMessage requestMessage) {
if (method == UpnpRequest.Method.POST || method == UpnpRequest.Method.NOTIFY) {
final MediaType mediaType = MediaType.get(requestMessage.getContentTypeHeader().getString());
if (requestMessage.getBodyType() == UpnpMessage.BodyType.STRING) {
body = RequestBody.create(mediaType, requestMessage.getBodyString());
body = RequestBody.create(requestMessage.getBodyString(), mediaType);
} else {
body = RequestBody.create(mediaType, requestMessage.getBodyBytes());
body = RequestBody.create(requestMessage.getBodyBytes(), mediaType);
}
} else {
body = null;
Expand Down

0 comments on commit c0f1dcc

Please sign in to comment.