diff --git a/build.gradle b/build.gradle index a00fd787..dd61c4ef 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ googleJavaFormat { include '**/*.java' } -def log4j_version = '2.19.0' +def log4j_version = '2.22.1' List logger = [ "org.apache.logging.log4j:log4j-api:$log4j_version", "org.apache.logging.log4j:log4j-core:$log4j_version", @@ -42,7 +42,7 @@ dependencies { //implementation 'org.fisco-bcos:solcJ:0.5.2.1' implementation 'org.fisco-bcos:solcJ:0.8.11.1' - implementation ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.6.0') { + implementation ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.7.0-SNAPSHOT') { exclude group: "org.slf4j" } @@ -53,7 +53,7 @@ dependencies { implementation('org.jline:jline:3.21.0') implementation('io.bretty:console-table-builder:1.2') implementation('com.github.jsqlparser:jsqlparser:2.0') - implementation('org.fisco-bcos.code-generator:bcos-code-generator:1.3.0') { + implementation('org.fisco-bcos.code-generator:bcos-code-generator:1.5.0-SNAPSHOT') { exclude group: "org.fisco-bcos.java-sdk" exclude group: "org.slf4j" } diff --git a/release_note.txt b/release_note.txt index 130165bc..d1e9cf3b 100644 --- a/release_note.txt +++ b/release_note.txt @@ -1 +1 @@ -v3.6.0 +v3.7.0 diff --git a/src/main/java/console/ConsoleInitializer.java b/src/main/java/console/ConsoleInitializer.java index af7a03aa..b33433ce 100644 --- a/src/main/java/console/ConsoleInitializer.java +++ b/src/main/java/console/ConsoleInitializer.java @@ -47,6 +47,9 @@ public class ConsoleInitializer { private LineReader lineReader; private boolean useV1TxService; + // v2 transaction extension + private byte[] extension; + public LineReader getLineReader() { return lineReader; } @@ -73,11 +76,20 @@ public void init(String[] args) throws ConfigException { if (args.length > 3 && "-v1".equals(args[3])) { // use v1 transaction service + logger.info("use v1 transaction service"); + useV1TxService = true; + } + if (args.length > 3 && "-v2".equals(args[3])) { + logger.info("use v2 transaction service"); useV1TxService = true; + extension = args.length > 4 ? args[4].getBytes() : null; } this.consoleClientFace = new ConsoleClientImpl(client); this.precompiledFace = new PrecompiledImpl(client); this.consoleContractFace = new ConsoleContractImpl(client, useV1TxService); + if (extension != null) { + ((ConsoleContractImpl) this.consoleContractFace).setExtension(extension); + } this.collaborationFace = new CollaborationImpl(client); this.authFace = new AuthImpl(client); } @@ -284,6 +296,9 @@ public void switchGroup(String[] params) { this.consoleClientFace = new ConsoleClientImpl(client); this.precompiledFace = new PrecompiledImpl(client); this.consoleContractFace = new ConsoleContractImpl(client, useV1TxService); + if (extension != null) { + ((ConsoleContractImpl) this.consoleContractFace).setExtension(extension); + } this.collaborationFace = new CollaborationImpl(client); this.authFace = new AuthImpl(client); JlineUtils.switchGroup(client); @@ -358,6 +373,9 @@ public void loadAccount(String[] params) { this.consoleClientFace = new ConsoleClientImpl(client); this.precompiledFace = new PrecompiledImpl(client); this.consoleContractFace = new ConsoleContractImpl(client, useV1TxService); + if (extension != null) { + ((ConsoleContractImpl) this.consoleContractFace).setExtension(extension); + } this.collaborationFace = new CollaborationImpl(client); this.authFace = new AuthImpl(client); System.out.println("Load account " + params[1] + " success!"); diff --git a/src/main/java/console/command/JlineUtils.java b/src/main/java/console/command/JlineUtils.java index aa870f02..ed2f40aa 100644 --- a/src/main/java/console/command/JlineUtils.java +++ b/src/main/java/console/command/JlineUtils.java @@ -17,8 +17,13 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Optional; +import java.util.Set; import org.fisco.bcos.sdk.v3.client.Client; +import org.fisco.bcos.sdk.v3.client.protocol.response.BcosGroupInfo; +import org.fisco.bcos.sdk.v3.client.protocol.response.BcosGroupInfoList; import org.fisco.bcos.sdk.v3.contract.precompiled.sysconfig.SystemConfigFeature; import org.fisco.bcos.sdk.v3.contract.precompiled.sysconfig.SystemConfigService; import org.fisco.bcos.sdk.v3.model.EnumNodeVersion; @@ -183,50 +188,45 @@ private static List generateComplters(Client client) { if (client.isEnableCommittee()) { commands.add(AuthOpCommand.SET_SYS_CONFIG_PROPOSAL.getCommand()); } + Set keys = new HashSet<>(); + keys.add(SystemConfigService.TX_COUNT_LIMIT); + keys.add(SystemConfigService.TX_GAS_LIMIT); + keys.add(SystemConfigService.TX_GAS_PRICE); + keys.add(SystemConfigService.CONSENSUS_PERIOD); + keys.add(SystemConfigService.COMPATIBILITY_VERSION); + keys.add(SystemConfigService.AUTH_STATUS); + for (SystemConfigFeature.Features feature : SystemConfigFeature.Features.values()) { + if (client.getChainCompatibilityVersion() + .compareTo(EnumNodeVersion.convertToVersion(feature.enableVersion())) + >= 0) { + keys.add(feature.toString()); + } + } + BcosGroupInfoList groupInfoList; + try { + groupInfoList = client.getGroupInfoList(); + Optional group = + groupInfoList + .getResult() + .stream() + .filter(groupInfo -> groupInfo.getGroupID().equals(client.getGroup())) + .findFirst(); + if (group.isPresent() && !group.get().getNodeList().isEmpty()) { + group.get() + .getNodeList() + .forEach(groupNodeInfo -> keys.addAll(groupNodeInfo.getFeatureKeys())); + } + } catch (Exception ignored) { + logger.info("Failed to get group info list, skip feature keys."); + } for (String command : commands) { - completers.add( - new ArgumentCompleter( - new StringsCompleter(command), - new StringsCompleter(SystemConfigService.TX_COUNT_LIMIT), - new StringsCompleterIgnoreCase())); - - completers.add( - new ArgumentCompleter( - new StringsCompleter(command), - new StringsCompleter(SystemConfigService.TX_GAS_LIMIT), - new StringsCompleterIgnoreCase())); - completers.add( - new ArgumentCompleter( - new StringsCompleter(command), - new StringsCompleter(SystemConfigService.TX_GAS_PRICE), - new StringsCompleterIgnoreCase())); - completers.add( - new ArgumentCompleter( - new StringsCompleter(command), - new StringsCompleter(SystemConfigService.CONSENSUS_PERIOD), - new StringsCompleterIgnoreCase())); - completers.add( - new ArgumentCompleter( - new StringsCompleter(command), - new StringsCompleter(SystemConfigService.COMPATIBILITY_VERSION), - new StringsCompleterIgnoreCase())); - completers.add( - new ArgumentCompleter( - new StringsCompleter(command), - new StringsCompleter(SystemConfigService.AUTH_STATUS), - new StringsCompleterIgnoreCase())); - for (SystemConfigFeature.Features feature : SystemConfigFeature.Features.values()) { - if (client.getChainCompatibilityVersion() - .compareTo( - EnumNodeVersion.convertToVersion(feature.enableVersion())) - >= 0) { - completers.add( - new ArgumentCompleter( - new StringsCompleter(command), - new StringsCompleter(feature.toString()), - new StringsCompleterIgnoreCase())); - } + for (String key : keys) { + completers.add( + new ArgumentCompleter( + new StringsCompleter(command), + new StringsCompleter(key), + new StringsCompleterIgnoreCase())); } } completers.add( diff --git a/src/main/java/console/common/ConsoleUtils.java b/src/main/java/console/common/ConsoleUtils.java index 1676f787..03220624 100644 --- a/src/main/java/console/common/ConsoleUtils.java +++ b/src/main/java/console/common/ConsoleUtils.java @@ -856,7 +856,7 @@ public static void main(String[] args) { "t", TRANSACTION_VERSION, true, - "[Optional] Specify transaction version interface, default is 0; If you want to use the latest transaction interface, please specify 1."); + "[Optional] Specify transaction version interface, default is 0; Supporting {0,1,2}; If you want to use the latest transaction interface, please specify 2."); transactionVersion.setRequired(false); options.addOption(transactionVersion); if (mode.equals("solidity")) { diff --git a/src/main/java/console/common/ConsoleVersion.java b/src/main/java/console/common/ConsoleVersion.java index c1adf690..d741ed94 100644 --- a/src/main/java/console/common/ConsoleVersion.java +++ b/src/main/java/console/common/ConsoleVersion.java @@ -2,7 +2,7 @@ public class ConsoleVersion { - public static final String Version = "3.6.0"; + public static final String Version = "3.7.0"; public static void main(String[] args) { System.out.println("console version: " + Version); diff --git a/src/main/java/console/contract/ConsoleContractImpl.java b/src/main/java/console/contract/ConsoleContractImpl.java index e4ea0898..c53b3aa6 100644 --- a/src/main/java/console/contract/ConsoleContractImpl.java +++ b/src/main/java/console/contract/ConsoleContractImpl.java @@ -88,7 +88,7 @@ public class ConsoleContractImpl implements ConsoleContractFace { private AssembleTransactionService assembleTransactionService = null; private final TransferTransactionService transferTransactionService; private final BFSService bfsService; - + private byte[] extension = null; private boolean useTransactionV1 = false; public ConsoleContractImpl(Client client) { @@ -117,6 +117,10 @@ public ConsoleContractImpl(Client client, boolean useTransactionV1) { } } + public void setExtension(byte[] extension) { + this.extension = extension; + } + @Override public void deploy(String[] params, String pwd) throws Exception { List paramsList = new ArrayList<>(Arrays.asList(params)); @@ -268,6 +272,7 @@ public TransactionResponse deploySolidity( if (useTransactionV1) { DeployTransactionRequestWithStringParams request = new TransactionRequestBuilder(abiAndBin.getAbi(), bin) + .setExtension(extension) .buildDeployStringParamsRequest(tempInputParams); response = assembleTransactionService.deployContract(request); } else { @@ -333,6 +338,7 @@ public TransactionResponse deployWasm( DeployTransactionRequestWithStringParams request = new TransactionRequestBuilder(abi, binStr) .setTo(path) + .setExtension(extension) .buildDeployStringParamsRequest(inputParams); response = assembleTransactionService.deployContract(request); } else { @@ -768,6 +774,7 @@ private void sendTransaction( if (useTransactionV1) { TransactionRequestWithStringParams request = new TransactionRequestBuilder(abiAndBin.getAbi(), functionName, contractAddress) + .setExtension(extension) .buildStringParamsRequest(callParams); response = assembleTransactionService.sendTransaction(request); } else { diff --git a/tools/download_console.sh b/tools/download_console.sh index 39155a14..f6ab3ae9 100755 --- a/tools/download_console.sh +++ b/tools/download_console.sh @@ -3,7 +3,7 @@ package_name="console.tar.gz" solcj_name="" solcj_default_version="solcJ-0.8.11.1.jar" only_solc_flag="" -default_version="3.6.0" +default_version="3.7.0" download_version="${default_version}" solc_download_version="3.0.0" specify_console=0