Skip to content

Commit d9480d0

Browse files
authored
Merge pull request #611 from cyjseagull/release-3.0.0-rc4
release 3.0.0 rc4
2 parents ab7e0a0 + 67bdc1e commit d9480d0

File tree

142 files changed

+4660
-3285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+4660
-3285
lines changed

Changelog.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
## v3.0.0-rc4
2+
(2022-7-1)
3+
4+
请阅读Java SDK v3.x+文档:
5+
6+
- [中文用户手册](https://fisco-bcos-doc.readthedocs.io/zh_CN/latest/docs/develop/sdk/java_sdk/index.html)
7+
8+
### 新增
9+
10+
* 新增`TableCRUDService`,适配v3.0.0-rc4节点的CRUD Table的接口
11+
* `AuthManger`
12+
* 新增共识节点变更提案、系统配置变更提案、升级计算逻辑提案等的接口
13+
* 新增冻结、解冻合约功能接口
14+
* 新增创建提案、修改合约ACL状态的异步接口
15+
* 新增批量获取提案的接口
16+
* 新增提案执行结果的事件监听接口
17+
18+
### 更新
19+
20+
* 使用密码库`webank-blockchain-java-crypto`替代`key-mini-toolkit`
21+
* 升级`bcos-sdk-jni``3.0.0-rc4`
22+
23+
### 修复
24+
25+
* 修复合约编解码相关的bug
26+
* 修复ReceiptParser获取预编译合约返回值时出现的编码问题
27+
* 增加单测覆盖率,修复大部分不合理的代码
28+
29+
### 兼容性说明
30+
31+
- 不兼容 FISCO BCOS 2.0+ 版本
32+
- 兼容java-sdk v3.x的历史版本
33+
- 支持[3.0.0-rc4](https://github.com/FISCO-BCOS/FISCO-BCOS/releases/tag/v3.0.0-rc4)版本
34+
35+
136
## v3.0.0-rc3
237
(2022-03-31)
338

build.gradle

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,30 @@ ext {
1717
ossrhPassword = "xxx"
1818
}
1919
// jackson version
20-
jacksonVersion = '2.12.4'
20+
jacksonVersion = '2.13.2.2'
2121
commonsIOVersion = '2.4'
2222
commonsLang3Version = '3.12.0'
2323
commonIOVersion = '2.4'
2424
javapoetVersion = '1.13.0'
2525
picocliVersion = '4.6.1'
2626
toml4jVersion = "0.7.2"
2727
bcprovJDK15onVersion = '1.69'
28-
keyMiniToolkit = "1.0.4"
28+
// keyMiniToolkit = "1.0.4"
29+
webankJavaCryptoVersion = "1.0.2"
2930

3031
junitVersion = '4.13.2'
3132
commonsCollections4Version = "4.4"
3233
guavaVersion = '30.1.1-jre'
3334

3435
config2Version = '2.7'
35-
bcosSdkJniVersion = "3.0.0-rc3"
36+
bcosSdkJniVersion = "3.0.0-rc4"
3637
}
3738

3839
// check.dependsOn integrationTest
3940
// integrationTest.mustRunAfter test
4041
allprojects {
4142
group = 'org.fisco-bcos.java-sdk'
42-
version = '3.0.0-rc3'
43+
version = '3.0.0-rc4'
4344
apply plugin: 'maven-publish'
4445
apply plugin: 'idea'
4546
apply plugin: 'eclipse'
@@ -76,6 +77,7 @@ allprojects {
7677
testImplementation("junit:junit:${junitVersion}")
7778
testImplementation("org.apache.commons:commons-collections4:${commonsCollections4Version}")
7879
testImplementation("com.google.guava:guava:${guavaVersion}")
80+
testImplementation("org.mockito:mockito-core:4.6.0")
7981
}
8082

8183
clean.doLast {
@@ -188,7 +190,8 @@ dependencies {
188190
api("commons-io:commons-io:${commonsIOVersion}")
189191
api("com.squareup:javapoet:${javapoetVersion}")
190192
api("info.picocli:picocli:${picocliVersion}")
191-
api("com.webank:key-mini-toolkit:${keyMiniToolkit}")
193+
// api("com.webank:key-mini-toolkit:${keyMiniToolkit}")
194+
api ("com.webank:webank-blockchain-java-crypto:${webankJavaCryptoVersion}")
192195
api("com.moandjiezana.toml:toml4j:${toml4jVersion}")
193196
api("org.apache.commons:commons-configuration2:${config2Version}")
194197

sdk-amop/src/main/java/org/fisco/bcos/sdk/v3/amop/Amop.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public interface Amop {
3737
*
3838
* @param configOption the config object
3939
* @return Amop instance
40+
* @throws JniException throw when build AMOP service failed
4041
*/
4142
static Amop build(ConfigOption configOption) throws JniException {
4243
long nativePointer = BcosSDKJniObj.create(configOption.getJniConfig());
@@ -49,11 +50,19 @@ static Amop build(ConfigOption configOption) throws JniException {
4950
*
5051
* @param nativePointer the
5152
* @return Amop instance
53+
* @throws JniException throw when build AMOP service failed
5254
*/
5355
static Amop build(long nativePointer) throws JniException {
5456
return new AmopImp(nativePointer);
5557
}
5658

59+
/**
60+
* Subscribe a normal topic.
61+
*
62+
* @param topics the topic name
63+
*/
64+
void subscribeTopic(Set<String> topics);
65+
5766
/**
5867
* Subscribe a normal topic.
5968
*
@@ -72,24 +81,27 @@ static Amop build(long nativePointer) throws JniException {
7281
/**
7382
* Send amop msg
7483
*
75-
* @param content the sent message
84+
* @param topic topic name
85+
* @param timeout timeout config
86+
* @param content the message be sent
7687
* @param callback the callback that will be called when receive the AMOP response
7788
*/
7889
void sendAmopMsg(String topic, byte[] content, int timeout, AmopResponseCallback callback);
7990

8091
/**
8192
* Send response msg
8293
*
83-
* @param endpoint
84-
* @param seq
85-
* @param conteng
94+
* @param endpoint send endpoint
95+
* @param seq response seq
96+
* @param content response content
8697
*/
87-
void sendResponse(String endpoint, String seq, byte[] conteng);
98+
void sendResponse(String endpoint, String seq, byte[] content);
8899

89100
/**
90101
* Send amop msg
91102
*
92-
* @param content the broadcasted AMOP message
103+
* @param topic topic name
104+
* @param content the AMOP message to be broadcast
93105
*/
94106
void broadcastAmopMsg(String topic, byte[] content);
95107

sdk-amop/src/main/java/org/fisco/bcos/sdk/v3/amop/AmopImp.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public AmopImp(long nativePointer) throws JniException {
3838
start();
3939
}
4040

41+
@Override
42+
public void subscribeTopic(Set<String> topics) {
43+
amopJni.subscribeTopic(topics);
44+
}
45+
4146
@Override
4247
public void subscribeTopic(String topicName, AmopRequestCallback callback) {
4348
amopJni.subscribeTopic(topicName, callback);

sdk-codec/src/main/java/org/fisco/bcos/sdk/v3/codec/ContractCodec.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.List;
2626
import org.apache.commons.lang3.tuple.Pair;
2727
import org.fisco.bcos.sdk.v3.codec.abi.Constant;
28+
import org.fisco.bcos.sdk.v3.codec.datatypes.AbiTypes;
2829
import org.fisco.bcos.sdk.v3.codec.datatypes.Address;
2930
import org.fisco.bcos.sdk.v3.codec.datatypes.Bool;
3031
import org.fisco.bcos.sdk.v3.codec.datatypes.DynamicArray;
@@ -100,7 +101,7 @@ public byte[] encodeConstructor(String abi, String bin, List<Object> params)
100101
ContractCodecTools.encode(
101102
ContractCodecTools.decodeABIObjectValue(inputABIObject, params),
102103
isWasm);
103-
return encodeConstructorFromBytes(bin, encodeParams, abi);
104+
return encodeConstructorFromBytes(bin, encodeParams);
104105
} catch (Exception e) {
105106
logger.error(" exception in encodeConstructor : {}", e.getMessage());
106107
}
@@ -131,7 +132,18 @@ private Type buildType(ABIDefinition.NamedType namedType, String param)
131132
Type element = buildType(subType, subNodeStr);
132133
elements.add(element);
133134
}
134-
type = paramType.isFixedList() ? new StaticArray(elements) : new DynamicArray(elements);
135+
if (elements.isEmpty()) {
136+
Class<? extends Type> arrayClass = AbiTypes.getType(paramType.rawType);
137+
type =
138+
paramType.isFixedList()
139+
? new StaticArray(arrayClass, elements)
140+
: new DynamicArray(arrayClass, elements);
141+
} else {
142+
type =
143+
paramType.isFixedList()
144+
? new StaticArray(elements.get(0).getClass(), elements)
145+
: new DynamicArray(elements.get(0).getClass(), elements);
146+
}
135147
return type;
136148
} else if (typeStr.equals("tuple")) {
137149
List<Type> components = new ArrayList<>();
@@ -330,7 +342,7 @@ public byte[] encodeConstructorFromString(String abi, String bin, List<String> p
330342
paramBytes =
331343
org.fisco.bcos.sdk.v3.codec.abi.FunctionEncoder.encodeConstructor(types);
332344
}
333-
return encodeConstructorFromBytes(bin, paramBytes, abi);
345+
return encodeConstructorFromBytes(bin, paramBytes);
334346
} catch (Exception e) {
335347
String errorMsg =
336348
" cannot encode in encodeMethodFromObject with appropriate interface ABI, cause:"
@@ -340,7 +352,7 @@ public byte[] encodeConstructorFromString(String abi, String bin, List<String> p
340352
}
341353
}
342354

343-
public byte[] encodeConstructorFromBytes(String bin, byte[] params, String abi)
355+
public byte[] encodeConstructorFromBytes(String bin, byte[] params)
344356
throws ContractCodecException {
345357
try {
346358
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -358,7 +370,6 @@ public byte[] encodeConstructorFromBytes(String bin, byte[] params, String abi)
358370
} else {
359371
deployParams.add(new Uint8(0));
360372
}
361-
// deployParams.add(new Utf8String(abi));
362373
outputStream.write(FunctionEncoder.encodeParameters(deployParams, null));
363374
}
364375
return outputStream.toByteArray();

sdk-codec/src/main/java/org/fisco/bcos/sdk/v3/codec/abi/FunctionReturnDecoder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public <T extends Type> Type decodeIndexedValue(
8181
|| Utf8String.class.isAssignableFrom(type)) {
8282
return TypeDecoder.decodeBytes(Hex.decode(input), Bytes32.class);
8383
} else {
84-
return TypeDecoder.decode(Hex.decode(input), 0, type);
84+
return TypeDecoder.decode(Hex.decode(input), 0, typeReference);
8585
}
8686
} catch (ClassNotFoundException e) {
8787
throw new UnsupportedOperationException("Invalid class reference provided", e);
@@ -143,7 +143,7 @@ private static List<Type> build(String input, List<TypeReference<Type>> outputPa
143143
offset += Type.MAX_BYTE_LENGTH * length;
144144
}
145145
} else {
146-
result = TypeDecoder.decode(rawInput, dataOffset, classType);
146+
result = TypeDecoder.decode(rawInput, dataOffset, typeReference);
147147
offset += Type.MAX_BYTE_LENGTH;
148148
}
149149
results.add(result);

0 commit comments

Comments
 (0)