Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/v3/client/ClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,15 @@ public void getPbftViewAsync(String node, RespCallback<PbftView> callback) {

@Override
public SystemConfig getSystemConfigByKey(String key) {
if (key.equals(SystemConfigService.TX_GAS_PRICE)) {
String gasPrice =
this.getSystemConfigByKey(nodeToSendRequest, key).getSystemConfig().getValue();
BigInteger gasPriceValue =
BigInteger.valueOf(Integer.parseInt(Hex.trimPrefix(gasPrice), 16));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
this.getSystemConfigByKey(nodeToSendRequest, key)
.getSystemConfig()
.setValue(gasPriceValue.toString());
}
return this.getSystemConfigByKey(nodeToSendRequest, key);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.fisco.bcos.sdk.v3.model.TransactionReceipt;
import org.fisco.bcos.sdk.v3.transaction.codec.decode.ReceiptParser;
import org.fisco.bcos.sdk.v3.transaction.model.exception.ContractException;
import org.fisco.bcos.sdk.v3.utils.Numeric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -40,6 +41,7 @@ public class SystemConfigService {
private final Client client;
public static final String TX_COUNT_LIMIT = "tx_count_limit";
public static final String TX_GAS_LIMIT = "tx_gas_limit";
public static final String TX_GAS_PRICE = "tx_gas_price";
public static final String CONSENSUS_PERIOD = "consensus_leader_period";
public static final String AUTH_STATUS = "auth_check_status";
public static final String COMPATIBILITY_VERSION = "compatibility_version";
Expand All @@ -53,6 +55,7 @@ public class SystemConfigService {
predicateMap.put(AUTH_STATUS, value -> value.compareTo(BigInteger.ZERO) >= 0);
predicateMap.put(
TX_GAS_LIMIT, value -> value.compareTo(BigInteger.valueOf(TX_GAS_LIMIT_MIN)) >= 0);
predicateMap.put(TX_GAS_PRICE, value -> value.compareTo(BigInteger.ZERO) >= 0);
}

public SystemConfigService(Client client, CryptoKeyPair credential) {
Expand Down Expand Up @@ -83,6 +86,10 @@ public RetCode setValueByKey(String key, String value) throws ContractException
&& SystemConfigFeature.fromString(key) == null) {
throw new ContractException("Unsupported feature key: [" + key + "]");
}
if (key.equals(TX_GAS_PRICE)) {
BigInteger gasPrice = new BigInteger(value);
value = Numeric.toHexString(gasPrice);
}

TransactionReceipt receipt = systemConfigPrecompiled.setValueByKey(key, value);
return ReceiptParser.parseTransactionReceipt(
Expand Down