diff --git a/build.gradle b/build.gradle index 3ab86628..beeb9f16 100644 --- a/build.gradle +++ b/build.gradle @@ -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.2.0') { + implementation('org.fisco-bcos.code-generator:bcos-code-generator:1.3.0-SNAPSHOT') { exclude group: "org.fisco-bcos.java-sdk" exclude group: "org.slf4j" } diff --git a/release_note.txt b/release_note.txt index c0c4025d..130165bc 100644 --- a/release_note.txt +++ b/release_note.txt @@ -1 +1 @@ -v3.5.0 +v3.6.0 diff --git a/src/main/java/console/ConsoleInitializer.java b/src/main/java/console/ConsoleInitializer.java index c3a9c97e..a853f687 100644 --- a/src/main/java/console/ConsoleInitializer.java +++ b/src/main/java/console/ConsoleInitializer.java @@ -171,25 +171,31 @@ private void loadAccountInfo(AccountInfo accountInfo, String groupID) { .getConfig() .getAccountConfig() .isAccountConfigured()) { - accountInfo = loadAccountRandomly(bcosSDK, client); - if (accountInfo != null) { + // load key from account dir + AccountInfo newAccountInfo = loadAccountRandomly(bcosSDK, client); + if (newAccountInfo != null) { this.client .getCryptoSuite() .loadAccount( - accountInfo.accountFileFormat, - accountInfo.accountFile, - accountInfo.password); + newAccountInfo.accountFileFormat, + newAccountInfo.accountFile, + newAccountInfo.password); } - if (accountInfo == null) { + if (newAccountInfo == null) { + // still not found key, use client crypto key pair // save the keyPair client.getCryptoSuite().getCryptoKeyPair().storeKeyPairWithPemFormat(); } } } catch (LoadKeyStoreException e) { - logger.warn( + logger.error( "loadAccountRandomly failed, try to generate and load the random account, error info: {}", e.getMessage(), e); + System.out.println( + "Failed to load the account from the keyStoreDir, error info: " + + e.getMessage()); + System.exit(0); } catch (Exception e) { System.out.println( "Failed to create BcosSDK failed! Please check the node status and the console configuration, error info: " @@ -237,12 +243,12 @@ private AccountInfo loadAccount(BcosSDK bcosSDK, String[] params) { System.out.println("Invalid param " + params[1] + ", must be -pem or -p12"); System.exit(0); } - if (params[1].compareToIgnoreCase("-pem") == 0 && params.length != 3) { + if (params[1].compareToIgnoreCase("-pem") == 0 && params.length < 3) { System.out.println( "Load account from the pem file failed! Please specified the pem file path"); System.exit(0); } - if (params[1].compareToIgnoreCase("-p12") == 0 && params.length != 3) { + if (params[1].compareToIgnoreCase("-p12") == 0 && params.length < 3) { System.out.println( "Load account from the p12 file failed! Please specified the p12 file path"); System.exit(0); diff --git a/src/main/java/console/auth/AuthImpl.java b/src/main/java/console/auth/AuthImpl.java index 0ee66f14..57384150 100644 --- a/src/main/java/console/auth/AuthImpl.java +++ b/src/main/java/console/auth/AuthImpl.java @@ -312,6 +312,14 @@ public void getProposalInfoList(String[] params) throws Exception { params[2], BigInteger.ONE, BigInteger.valueOf(Integer.MAX_VALUE)); + if (from.compareTo(to) > 0) { + System.out.println("Query From should be less than To."); + return; + } + if (to.subtract(from).compareTo(BigInteger.valueOf(100)) > 0) { + System.out.println("Query range should be less than 100."); + return; + } List proposalInfoList = authManager.getProposalInfoList(from, to); int showFrom = from.intValue(); for (ProposalInfo proposalInfo : proposalInfoList) { diff --git a/src/main/java/console/common/ConsoleUtils.java b/src/main/java/console/common/ConsoleUtils.java index 84a4da1f..1676f787 100644 --- a/src/main/java/console/common/ConsoleUtils.java +++ b/src/main/java/console/common/ConsoleUtils.java @@ -318,7 +318,8 @@ public static void compileSolToJava( String librariesOption, String specifyContract, boolean isContractParallelAnalysis, - boolean enableAsyncCall) + boolean enableAsyncCall, + String transactionVersion) throws IOException, CompileContractException { String contractName = solFile.getName().split("\\.")[0]; @@ -360,6 +361,10 @@ public static void compileSolToJava( if (enableAsyncCall) { args.add("-e"); } + if (!transactionVersion.equals("V0")) { + args.add("-t"); + args.add(transactionVersion); + } CodeGenMain.main(args.toArray(new String[0])); System.out.println( "*** Convert solidity to java for " + solFile.getName() + " success ***\n"); @@ -372,7 +377,8 @@ public static void compileAllSolToJava( String abiDir, String binDir, boolean isContractParallelAnalysis, - boolean enableAsyncCall) + boolean enableAsyncCall, + String transactionVersion) throws IOException { File[] solFiles = solFileList.listFiles(); if (solFiles.length == 0) { @@ -397,7 +403,8 @@ public static void compileAllSolToJava( null, null, isContractParallelAnalysis, - enableAsyncCall); + enableAsyncCall, + transactionVersion); } catch (Exception e) { System.out.println( "ERROR:convert solidity to java for " @@ -842,7 +849,16 @@ public static void main(String[] args) { String NO_ANALYSIS_OPTION = "no-analysis"; String ENABLE_ASYNC_CALL_OPTION = "enable-async-call"; + String TRANSACTION_VERSION = "transaction-version"; + Option transactionVersion = + new Option( + "t", + TRANSACTION_VERSION, + true, + "[Optional] Specify transaction version interface, default is 0; If you want to use the latest transaction interface, please specify 1."); + transactionVersion.setRequired(false); + options.addOption(transactionVersion); if (mode.equals("solidity")) { Option solidityFilePathOption = new Option( @@ -934,6 +950,7 @@ public static void main(String[] args) { String pkgName = cmd.getOptionValue(PACKAGE_OPTION, DEFAULT_PACKAGE); String javaDir = cmd.getOptionValue(OUTPUT_OPTION, DEFAULT_OUTPUT); + String transactionVersionStr = "V" + cmd.getOptionValue(TRANSACTION_VERSION, "0"); if (mode.equals("solidity")) { String solPathOrDir = cmd.getOptionValue(SOL_OPTION, DEFAULT_SOL); String librariesOption = cmd.getOptionValue(LIBS_OPTION, ""); @@ -963,7 +980,8 @@ public static void main(String[] args) { librariesOption, specifyContract, useDagAnalysis, - enableAsyncCall); + enableAsyncCall, + transactionVersionStr); } else { // input dir compileAllSolToJava( fullJavaDir, @@ -972,7 +990,8 @@ public static void main(String[] args) { ABI_PATH, BIN_PATH, useDagAnalysis, - enableAsyncCall); + enableAsyncCall, + transactionVersionStr); } } catch (IOException | CompileContractException e) { System.out.print(e.getMessage()); @@ -985,15 +1004,20 @@ public static void main(String[] args) { String abiFile = cmd.getOptionValue(ABI_OPTION); String binFile = cmd.getOptionValue(BIN_OPTION); String smBinFile = cmd.getOptionValue(SM_BIN_OPTION); - CodeGenMain.main( - Arrays.asList( + List params = + new ArrayList<>( + Arrays.asList( "-v", "V3", "-a", abiFile, "-b", binFile, "-s", smBinFile, "-p", pkgName, - "-o", javaDir) - .toArray(new String[0])); + "-o", javaDir)); + if (!transactionVersionStr.equals("0")) { + params.add("-t"); + params.add(transactionVersionStr); + } + CodeGenMain.main(params.toArray(new String[0])); } } } diff --git a/src/main/java/console/common/ConsoleVersion.java b/src/main/java/console/common/ConsoleVersion.java index d373e0d3..c1adf690 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.5.0"; + public static final String Version = "3.6.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 74113d32..2c0d4798 100644 --- a/src/main/java/console/contract/ConsoleContractImpl.java +++ b/src/main/java/console/contract/ConsoleContractImpl.java @@ -260,7 +260,7 @@ public TransactionResponse deploySolidity( DeployTransactionRequestWithStringParams request = new TransactionRequestBuilder(abiAndBin.getAbi(), bin) .buildDeployStringParamsRequest(tempInputParams); - response = assembleTransactionService.deployContractWithStringParams(request); + response = assembleTransactionService.deployContract(request); } else { response = this.assembleTransactionProcessor.deployAndGetResponseWithStringParams( @@ -325,7 +325,7 @@ public TransactionResponse deployWasm( new TransactionRequestBuilder(abi, binStr) .setTo(path) .buildDeployStringParamsRequest(inputParams); - response = assembleTransactionService.deployContractWithStringParams(request); + response = assembleTransactionService.deployContract(request); } else { response = this.assembleTransactionProcessor.deployAndGetResponseWithStringParams( @@ -760,7 +760,7 @@ private void sendTransaction( TransactionRequestWithStringParams request = new TransactionRequestBuilder(abiAndBin.getAbi(), functionName, contractAddress) .buildStringParamsRequest(callParams); - response = assembleTransactionService.sendTransactionWithStringParams(request); + response = assembleTransactionService.sendTransaction(request); } else { response = assembleTransactionProcessor.sendTransactionWithStringParamsAndGetResponse( diff --git a/src/main/java/console/precompiled/PrecompiledImpl.java b/src/main/java/console/precompiled/PrecompiledImpl.java index 7fff90f2..df6ae22a 100644 --- a/src/main/java/console/precompiled/PrecompiledImpl.java +++ b/src/main/java/console/precompiled/PrecompiledImpl.java @@ -853,7 +853,16 @@ private Tuple2 travelBfs( if (deep >= limit) return new Tuple2<>(0, 0); int dirCount = 0; int contractCount = 0; - List children = bfsService.list(absolutePath); + BigInteger offset = BigInteger.ZERO; + EnumNodeVersion.Version supportedVersion = bfsService.getCurrentVersion(); + Tuple2> fileInfoList; + if (supportedVersion.compareTo(EnumNodeVersion.BCOS_3_1_0.toVersionObj()) >= 0) { + fileInfoList = bfsService.list(absolutePath, offset, Common.LS_DEFAULT_COUNT); + } else { + fileInfoList = new Tuple2<>(BigInteger.ZERO, bfsService.list(absolutePath)); + } + BigInteger fileLeft = fileInfoList.getValue1(); + List children = fileInfoList.getValue2(); for (int i = 0; i < children.size(); i++) { String thisPrefix = ""; String nextPrefix = ""; @@ -863,7 +872,11 @@ private Tuple2 travelBfs( thisPrefix = prefix + "├─"; } else { nextPrefix = prefix + " "; - thisPrefix = prefix + "└─"; + if (fileLeft.compareTo(BigInteger.ZERO) > 0) { + thisPrefix = prefix + "├─"; + } else { + thisPrefix = prefix + "└─"; + } } System.out.println(thisPrefix + children.get(i).getFileName()); if (children.get(i).getFileType().equals(Common.BFS_TYPE_DIR)) { @@ -881,6 +894,9 @@ private Tuple2 travelBfs( } else { contractCount++; } + if (fileLeft.compareTo(BigInteger.ZERO) > 0 && i == children.size() - 1) { + System.out.println(prefix + "└─" + "... " + fileLeft + " left files..."); + } } } return new Tuple2<>(dirCount, contractCount); diff --git a/tools/download_console.sh b/tools/download_console.sh index 72c81ea5..39155a14 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.5.0" +default_version="3.6.0" download_version="${default_version}" solc_download_version="3.0.0" specify_console=0