Skip to content

Commit

Permalink
Merge branch 'release-3.6.0' of https://github.com/FISCO-BCOS/console
Browse files Browse the repository at this point in the history
…into listCaller
  • Loading branch information
wenlinlee committed Jan 10, 2024
2 parents b00319b + 4d1b13d commit 79f3083
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion release_note.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.5.0
v3.6.0
24 changes: 15 additions & 9 deletions src/main/java/console/ConsoleInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/console/auth/AuthImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProposalInfo> proposalInfoList = authManager.getProposalInfoList(from, to);
int showFrom = from.intValue();
for (ProposalInfo proposalInfo : proposalInfoList) {
Expand Down
42 changes: 33 additions & 9 deletions src/main/java/console/common/ConsoleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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");
Expand All @@ -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) {
Expand All @@ -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 "
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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, "");
Expand Down Expand Up @@ -963,7 +980,8 @@ public static void main(String[] args) {
librariesOption,
specifyContract,
useDagAnalysis,
enableAsyncCall);
enableAsyncCall,
transactionVersionStr);
} else { // input dir
compileAllSolToJava(
fullJavaDir,
Expand All @@ -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());
Expand All @@ -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<String> 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]));
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/console/common/ConsoleVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/console/contract/ConsoleContractImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/console/precompiled/PrecompiledImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,16 @@ private Tuple2<Integer, Integer> travelBfs(
if (deep >= limit) return new Tuple2<>(0, 0);
int dirCount = 0;
int contractCount = 0;
List<BfsInfo> children = bfsService.list(absolutePath);
BigInteger offset = BigInteger.ZERO;
EnumNodeVersion.Version supportedVersion = bfsService.getCurrentVersion();
Tuple2<BigInteger, List<BfsInfo>> 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<BfsInfo> children = fileInfoList.getValue2();
for (int i = 0; i < children.size(); i++) {
String thisPrefix = "";
String nextPrefix = "";
Expand All @@ -863,7 +872,11 @@ private Tuple2<Integer, Integer> 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)) {
Expand All @@ -881,6 +894,9 @@ private Tuple2<Integer, Integer> 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);
Expand Down
2 changes: 1 addition & 1 deletion tools/download_console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79f3083

Please sign in to comment.