Skip to content

Commit 4ccdd18

Browse files
committed
<feat&fix>(transaction): fix call with sign result not handle revert message bug, add system features.
1 parent d107ca6 commit 4ccdd18

File tree

3 files changed

+70
-12
lines changed

3 files changed

+70
-12
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.fisco.bcos.sdk.v3.contract.precompiled.sysconfig;
2+
3+
import org.fisco.bcos.sdk.v3.model.EnumNodeVersion;
4+
5+
public class SystemConfigFeature {
6+
public enum Features {
7+
BUGFIX_REVERT("bugfix_revert", EnumNodeVersion.BCOS_3_2_3.getVersion()),
8+
FEATURE_SHARDING("feature_sharding", EnumNodeVersion.BCOS_3_5_0.getVersion()),
9+
FEATURE_RPBFT("feature_rpbft", EnumNodeVersion.BCOS_3_5_0.getVersion()),
10+
FEATURE_PAILLIER("feature_paillier", EnumNodeVersion.BCOS_3_5_0.getVersion());
11+
12+
private final String featureName;
13+
private final int enableVersion;
14+
15+
Features(String name, int enableVersion) {
16+
this.featureName = name;
17+
this.enableVersion = enableVersion;
18+
}
19+
20+
@Override
21+
public String toString() {
22+
return featureName;
23+
}
24+
25+
public int enableVersion() {
26+
return enableVersion;
27+
}
28+
}
29+
30+
public static Features fromString(String name) {
31+
switch (name) {
32+
case "bugfix_revert":
33+
return Features.BUGFIX_REVERT;
34+
case "feature_sharding":
35+
return Features.FEATURE_SHARDING;
36+
case "feature_rpbft":
37+
return Features.FEATURE_RPBFT;
38+
case "feature_paillier":
39+
return Features.FEATURE_PAILLIER;
40+
default:
41+
return null;
42+
}
43+
}
44+
}

src/main/java/org/fisco/bcos/sdk/v3/model/EnumNodeVersion.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ public enum EnumNodeVersion {
99
BCOS_3_0_0(0x03000000),
1010
BCOS_3_1_0(0x03010000),
1111
BCOS_3_2_0(0x03020000),
12+
BCOS_3_2_3(0x03020300),
1213
BCOS_3_3_0(0x03030000),
13-
BCOS_3_4_0(0x03040000);
14+
BCOS_3_4_0(0x03040000),
15+
BCOS_3_5_0(0x03050000);
1416

1517
private final Integer version;
1618
private static final Map<Integer, EnumNodeVersion> versionLookupMap = new HashMap<>();
@@ -20,8 +22,10 @@ public enum EnumNodeVersion {
2022
versionLookupMap.put(0x03000000, BCOS_3_0_0);
2123
versionLookupMap.put(0x03010000, BCOS_3_1_0);
2224
versionLookupMap.put(0x03020000, BCOS_3_2_0);
25+
versionLookupMap.put(0x03020300, BCOS_3_2_3);
2326
versionLookupMap.put(0x03030000, BCOS_3_3_0);
2427
versionLookupMap.put(0x03040000, BCOS_3_4_0);
28+
versionLookupMap.put(0x03050000, BCOS_3_5_0);
2529
}
2630

2731
EnumNodeVersion(Integer version) {
@@ -46,6 +50,8 @@ public String getVersionString() {
4650
return "3.3.0";
4751
case BCOS_3_4_0:
4852
return "3.4.0";
53+
case BCOS_3_5_0:
54+
return "3.5.0";
4955
case UNKNOWN:
5056
default:
5157
return "0.0.0";

src/main/java/org/fisco/bcos/sdk/v3/transaction/manager/AssembleTransactionProcessor.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -883,35 +883,43 @@ public CallResponse callAndGetResponse(
883883
String from, String to, String abi, String functionName, byte[] data)
884884
throws ContractCodecException, TransactionBaseException {
885885
Call call = this.executeCall(from, to, data);
886+
CallResponse callResponse = this.parseCallResponseStatus(call.getCallResult());
886887
ABIObject decodedResult =
887888
this.contractCodec.decodeMethodAndGetOutputAbiObject(
888889
abi, functionName, call.getCallResult().getOutput());
889-
return getCallResponse(call, decodedResult);
890+
Pair<List<Object>, List<ABIObject>> outputObject =
891+
ContractCodecTools.decodeJavaObjectAndGetOutputObject(decodedResult);
892+
callResponse.setReturnObject(outputObject.getLeft());
893+
callResponse.setReturnABIObject(outputObject.getRight());
894+
try {
895+
callResponse.setResults(ContractCodecTools.getABIObjectTypeListResult(decodedResult));
896+
} catch (Exception ignored) {
897+
log.error("decode results failed, ignored. value: {}", decodedResult);
898+
}
899+
return callResponse;
890900
}
891901

892902
public CallResponse callAndGetResponse(
893903
String from, String to, ABIDefinition abiDefinition, byte[] data)
894904
throws ContractCodecException, TransactionBaseException {
895905
Call call = this.executeCall(from, to, data);
896-
ABIObject abiObject =
897-
contractCodec.decodeMethodAndGetOutAbiObjectByABIDefinition(
898-
abiDefinition, call.getCallResult().getOutput());
899-
return getCallResponse(call, abiObject);
906+
return getCallResponse(call, abiDefinition);
900907
}
901908

902909
public CallResponse callWithSignAndGetResponse(
903910
String from, String to, ABIDefinition abiDefinition, byte[] data)
904911
throws ContractCodecException, TransactionBaseException {
905912
Call call = this.executeCallWithSign(from, to, data);
906-
ABIObject abiObject =
907-
contractCodec.decodeMethodAndGetOutAbiObjectByABIDefinition(
908-
abiDefinition, call.getCallResult().getOutput());
909-
return getCallResponse(call, abiObject);
913+
914+
return getCallResponse(call, abiDefinition);
910915
}
911916

912-
public CallResponse getCallResponse(Call call, ABIObject decodedResult)
913-
throws TransactionBaseException {
917+
public CallResponse getCallResponse(Call call, ABIDefinition abiDefinition)
918+
throws TransactionBaseException, ContractCodecException {
914919
CallResponse callResponse = this.parseCallResponseStatus(call.getCallResult());
920+
ABIObject decodedResult =
921+
contractCodec.decodeMethodAndGetOutAbiObjectByABIDefinition(
922+
abiDefinition, call.getCallResult().getOutput());
915923
Pair<List<Object>, List<ABIObject>> outputObject =
916924
ContractCodecTools.decodeJavaObjectAndGetOutputObject(decodedResult);
917925
callResponse.setReturnObject(outputObject.getLeft());

0 commit comments

Comments
 (0)