[#2766]fix: clean up deprecation warnings (#3511)

* 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>
This commit is contained in:
Sandra Wang
2022-03-10 23:08:55 -05:00
committed by GitHub
parent f81fa43c27
commit 69a375b823
8 changed files with 15 additions and 11 deletions

View File

@@ -72,7 +72,7 @@ public class PayloadIdentifier implements Quantity {
@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;
}

View File

@@ -41,6 +41,6 @@ public class PayloadIdentifierTest {
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);
}
}

View File

@@ -21,6 +21,7 @@ import static com.google.errorprone.util.ASTHelpers.getType;
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;
@@ -29,6 +30,7 @@ import com.google.errorprone.BugPattern;
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;
@@ -60,8 +62,10 @@ public class PrivateStaticFinalLoggers extends BugChecker implements VariableTre
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();
}
}

View File

@@ -103,6 +103,6 @@ public abstract class ClassicDifficultyCalculators {
}
private static BigInteger difficulty(final Quantity value) {
return (BigInteger) value.getValue();
return value.getAsBigInteger();
}
}

View File

@@ -138,6 +138,6 @@ public abstract class MainnetDifficultyCalculators {
}
private static BigInteger difficulty(final Quantity value) {
return (BigInteger) value.getValue();
return value.getAsBigInteger();
}
}

View File

@@ -84,7 +84,7 @@ public class BaseFeePendingTransactionsSorter extends AbstractPendingTransaction
.getMaxPriorityFeePerGas()
// safe to .get() here because only 1559 txs can be in the static range
.get()
.getValue()
.getAsBigInteger()
.longValue())
.thenComparing(TransactionInfo::getSequence)
.reversed());
@@ -97,7 +97,7 @@ public class BaseFeePendingTransactionsSorter extends AbstractPendingTransaction
transactionInfo
.getTransaction()
.getMaxFeePerGas()
.map(maxFeePerGas -> maxFeePerGas.getValue().longValue())
.map(maxFeePerGas -> maxFeePerGas.getAsBigInteger().longValue())
.orElse(transactionInfo.getGasPrice().toLong()))
.thenComparing(TransactionInfo::getSequence)
.reversed());

View File

@@ -440,9 +440,9 @@ public class EthStatsService {
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();
}
}

View File

@@ -50,9 +50,9 @@ public class OkHttpStreamClient extends AbstractStreamClient<StreamClientConfigu
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;