Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<feat>(console): adapt code-gen 1.3.0. #812

Merged
merged 1 commit into from
Dec 28, 2023
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
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
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]));
}
}
}
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
Loading