Skip to content

Commit 1f46228

Browse files
Maggie WUcyjseagull
authored andcommitted
sync code, solve conflict
1 parent be6240a commit 1f46228

File tree

17 files changed

+426
-65
lines changed

17 files changed

+426
-65
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ conf/
2222
gmcert.cnf
2323
gmsm2.param
2424
integrationTestEnv.sh
25+
gradle.properties
26+
gpg.gpg

CONTRIBUTING.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
English / [中文](docs/CONTRIBUTING_CN.md)
2+
3+
# Contributing and Review Guidelines
4+
5+
All contributions are welcome!
6+
7+
## Branching
8+
9+
Our branching method is [git-flow](https://jeffkreeftmeijer.com/git-flow/)
10+
11+
- **master**: Latest stable branch
12+
- **dev**: Stable branch waiting for release(merge to master)
13+
- **feature-xxxx**: A developing branch of a new feature named xxxx
14+
- **bugfix-xxxx**: A branch to fix the bug named xxxx
15+
16+
## How to
17+
18+
### Issue
19+
20+
Go to [issues page](https://github.com/FISCO-BCOS/java-sdk/issues)
21+
22+
### Fix bugs
23+
24+
1. **Fork** this repo
25+
2. **Create** a new branch named **bugfix-xxxx** forked from your repo's **master** branch
26+
3. **Fix** the bug
27+
4. **Test** the fixed code
28+
5. Make **pull request** back to this repo's **dev** branch
29+
6. Wait the community to review the code
30+
7. Merged(**Bug fixed**)
31+
32+
### Develop a new feature
33+
34+
1. **Fork** this repo
35+
2. **Create** a new branch named **feature-xxxx** forked from your repo's **dev** branch
36+
3. **Coding** in feature-xxxx
37+
4. **Pull** this repo's dev branch to your feature-xxxx constantly
38+
5. **Test** your code
39+
6. Make **pull request** back to this repo's dev branch
40+
7. Wait the community to review the code
41+
8. Merged !!!!
42+
43+
## Code formatting
44+
45+
The code formatting tool are described by the [google-java-format-gradle-plugin](https://github.com/sherter/google-java-format-gradle-plugin).
46+
47+
Execute the task `googleJavaFormat` to format all *.java files in the project
48+
```
49+
./gradlew goJF
50+
```
51+
Execute the task `verifyGoogleJavaFormat` to verify that all *.java files are formatted properly
52+
```
53+
./gradlew verGJF
54+
```
55+
56+
## Continuous integration
57+
58+
**Continuous integration platform**
59+
60+
* travis-ci: [![Build Status](https://travis-ci.org/FISCO-BCOS/java-sdk.svg?branch=master)](https://travis-ci.org/FISCO-BCOS/java-sdk)
61+
62+
63+
**Code quality**
64+
65+
* Codacy: [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d830a3be25c04b04b032870e4184482a)](https://www.codacy.com/gh/FISCO-BCOS/java-sdk/dashboard?utm_source=github.com&utm_medium=referral&utm_content=FISCO-BCOS/java-sdk&utm_campaign=Badge_Grade)
66+
67+

Changelog.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### v2.6.1-rc1
2+
3+
(2020-09-30)
4+
5+
This java sdk is a code refactoring version base on web3sdk 2.6.1. It includes the following new features:
6+
7+
* Support Toml config file, simplify configuration options.
8+
* Support connecting with nodes of different groups.
9+
* Support AMOP subscription and unsubscription at any time instead of just before start service.
10+
* ABI module add support of encode and decode of struct type data.
11+
* Use the common crypto tools of WeBank.
12+
* Add a new module called group management to help applications manage nodes which java SDK connecting with.
13+
* Use modular design, each module can use independently. For example, you can create crypto.jar file if only crypto module is needed.
14+
15+
Please note that:
16+
Java SDK supports FISCO BCOS 2.X, but not compatible with web3sdk. Mean, when tow user want to use AMOP functions to talk with each other, they should either both use java sdk, or both use web3sdk.

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
11
![](docs/images/FISCO_BCOS_Logo.svg)
22

3+
English / [中文](docs/README_CN.md)
4+
35
# Java SDK
46

57
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
68
[![Build Status](https://travis-ci.org/FISCO-BCOS/java-sdk.svg?branch=master)](https://travis-ci.org/FISCO-BCOS/java-sdk)
79
[![CodeFactor](https://www.codefactor.io/repository/github/fisco-bcos/java-sdk/badge)](https://www.codefactor.io/repository/github/fisco-bcos/java-sdk)
810
[![GitHub All Releases](https://img.shields.io/github/downloads/FISCO-BCOS/java-sdk/total.svg)](https://github.com/FISCO-BCOS/java-sdk)
911

12+
This is the FISCO BCOS Client SDK for Java. Developers can use Java SDK to build blockchain applications with FISCO BCOS blockchain.
13+
14+
## Functions
15+
* Contract compiling.
16+
* Interacting with FISCO BCOS JSON-RPC interface.
17+
* constructing and sending transactions.
18+
* Advanced Messages Onchain Protocol(AMOP) functions.
19+
* Contract event subscription.
20+
* Encoding and decoding data with ABI.
21+
* Account Management.
22+
23+
## New Features
24+
This java sdk is a code refactoring version base on web3sdk (not recommend to use), it includes the following new features:
25+
26+
* Support Toml config file, simplify configuration options.
27+
* Support connecting with nodes of different groups.
28+
* Support AMOP subscription and unsubscription at any time instead of just before start service.
29+
* ABI module add support of encode and decode of struct type data.
30+
* Use the common crypto tools of WeBank.
31+
* Add a new module called group management to help applications manage nodes which java SDK connecting with.
32+
* Use modular design, each module can use independently. For example, you can create crypto.jar file if only crypto module is needed.
33+
34+
## Documentation
35+
* [English User Handbook](https://fisco-bcos-documentation.readthedocs.io/en/latest/docs/sdk/java_sdk/index.html)
36+
* [Chinese User Handbook](https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/sdk/java_sdk/index.html#)
37+
* [Chinese WIKI](https://github.com/FISCO-BCOS/java-sdk/wiki)
38+
39+
## Quick Start
40+
* [English](https://fisco-bcos-documentation.readthedocs.io/en/latest/docs/sdk/java_sdk/quick_start.html)
41+
* [Chinese](https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/sdk/java_sdk/quick_start.html)
1042

1143
## Join Our Community
1244

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ext {
2323
nettySMSSLContextVersion = "1.1.0"
2424
toml4jVersion = "0.7.2"
2525
bcprovJDK15onVersion = "1.60"
26-
keyMiniToolkit = "1.0-SNAPSHOT"
26+
keyMiniToolkit = "1.0.0"
2727

2828
solcJVersion = "0.4.25.1"
2929
//solcJVersion = "0.5.2.0"

docs/CONTRIBUTING_CN.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[English](../CONTRIBUTING.md) / 中文
2+
3+
# 贡献代码
4+
5+
非常感谢能有心为FISCO-BCOS社区贡献代码!
6+
7+
## 分支策略
8+
9+
项目采用[git-flow](https://jeffkreeftmeijer.com/git-flow/)的分支策略。
10+
11+
* master:最新的稳定分支
12+
* dev:待发布的稳定分支
13+
* feature-xxxx:一个正在开发xxxx特性分支
14+
* bugfix-xxxx:一个正在修bug xxxx的分支
15+
16+
## 贡献方法
17+
18+
### Issue
19+
20+
可直接去[issues page](https://github.com/FISCO-BCOS/java-sdk/issues)提issue。
21+
22+
### 修复bug
23+
24+
1. Fork本仓库到个人仓库
25+
2. 从个人仓库的master分支拉出一个bugfix-xxxx分支
26+
3. 在bugfix-xxxx上修复bug
27+
4. 测试修复的bug
28+
5. PR(Pull Request)到本仓库的dev分支
29+
6. 等待社区review这个PR
30+
7. PR合入,bug修复完成!
31+
32+
### 开发新特性
33+
34+
1. Fork本仓库到个人仓库
35+
2. 从个人仓库的dev分支拉出一个feature-xxxx分支
36+
3. 在feature-xxxx上进行特性开发
37+
4. 不定期的从本仓库的dev分支pull最新的改动到feature-xxxx分支
38+
5. 测试新特性
39+
6. PR(Pull Request)到本参考的dev分支
40+
7. 等待社区review这个PR
41+
8. PR合入,特性开发完成!
42+
43+
## 代码格式化
44+
45+
代码格式化gradle插件[google-java-format-gradle-plugin](https://github.com/sherter/google-java-format-gradle-plugin).
46+
47+
执行任务 `googleJavaFormat`格式化java文件。
48+
```
49+
./gradlew goJF
50+
```
51+
执行任务 `verifyGoogleJavaFormat`验证java文件是否格式化完成
52+
```
53+
./gradlew verGJF
54+
```
55+
56+
## 持续集成(CI)
57+
58+
持续集成框架
59+
60+
* travis-ci: [![Build Status](https://travis-ci.org/FISCO-BCOS/java-sdk.svg?branch=master)](https://travis-ci.org/FISCO-BCOS/java-sdk)
61+
62+
63+
代码质量
64+
65+
* Codacy: [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d830a3be25c04b04b032870e4184482a)](https://www.codacy.com/gh/FISCO-BCOS/java-sdk/dashboard?utm_source=github.com&utm_medium=referral&utm_content=FISCO-BCOS/java-sdk&utm_campaign=Badge_Grade)
66+
67+

docs/README_CN.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
![](images/FISCO_BCOS_Logo.svg)
2+
3+
[English](../README.md) / 中文
4+
5+
# Java SDK
6+
7+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
8+
[![Build Status](https://travis-ci.org/FISCO-BCOS/java-sdk.svg?branch=master)](https://travis-ci.org/FISCO-BCOS/java-sdk)
9+
[![CodeFactor](https://www.codefactor.io/repository/github/fisco-bcos/java-sdk/badge)](https://www.codefactor.io/repository/github/fisco-bcos/java-sdk)
10+
[![GitHub All Releases](https://img.shields.io/github/downloads/FISCO-BCOS/java-sdk/total.svg)](https://github.com/FISCO-BCOS/java-sdk)
11+
12+
这是FISCO BCOS客户端的Java SDK,提供了访问FISCO BCOS节点的Java API,支持节点状态查询、部署和调用合约等功能,基于Java SDK可开发区块链应用,目前支持FISCO BCOS 2.0+。
13+
14+
## 功能
15+
* 提供合约编译功能,将Solidity合约文件转换成Java合约文件
16+
* 提供Java SDK API,提供访问FISCO BCOS JSON-RPC 的功能,并支持预编译(Precompiled)合约调用
17+
* 提供自定义构造和发送交易功能
18+
* 提供AMOP功能
19+
* 支持合约事件推送
20+
* 支持ABI解析
21+
* 提供账户管理接口
22+
23+
## 新特性
24+
这个Java SDK是web3sdk(不推荐使用)的重构版本,其包含如下几个新特性:
25+
26+
* 支持Toml配置文件的配置,简化配置项。
27+
* 支持连接不同群组的节点。
28+
* 支持AMOP动态订阅和取消订阅。
29+
* 支持解析结构体类型数据的ABI解析。
30+
* 使用Webank通用的加密包。
31+
* 添加群组管理模块,帮助应用管理多个群组中节点连接。
32+
* 使用模块化设计,便于组装再造。
33+
34+
## 贡献代码
35+
欢迎参与FISCO BCOS的社区建设:
36+
- 点亮我们的小星星(点击项目左上方Star按钮)。
37+
- 提交代码(Pull requests),参考我们的[代码贡献流程](CONTRIBUTING_CN.md)
38+
- [提问和提交BUG](https://github.com/FISCO-BCOS/java-sdk/issues)
39+
40+
## 加入我们的社区
41+
42+
FISCO BCOS开源社区是国内活跃的开源社区,社区长期为机构和个人开发者提供各类支持与帮助。已有来自各行业的数千名技术爱好者在研究和使用FISCO BCOS。如您对FISCO BCOS开源技术及应用感兴趣,欢迎加入社区获得更多支持与帮助。
43+
44+
45+
![](https://media.githubusercontent.com/media/FISCO-BCOS/LargeFiles/master/images/QR_image.png)
46+
47+
48+
## License
49+
50+
![license](https://img.shields.io/badge/license-Apache%20v2-blue.svg)
51+
52+
Web3SDK的开源协议为[Apache License 2.0](http://www.apache.org/licenses/). 详情参考[LICENSE](../LICENSE)

sdk-core/src/main/java/org/fisco/bcos/sdk/channel/ResponseCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void onError(String errorMessage) {
5757
cancelTimeout();
5858
Response response = new Response();
5959
response.setErrorCode(ChannelMessageError.INTERNAL_MESSAGE_HANDLE_FAILED.getError());
60-
response.setContent(errorMessage);
60+
response.setErrorMessage(errorMessage);
6161
onResponse(response);
6262
}
6363

sdk-core/src/main/java/org/fisco/bcos/sdk/network/ConnectionManager.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,19 @@ private SslContext initSslContext(ConfigOption configOption) throws NetworkExcep
231231
.build();
232232
return sslCtx;
233233
} catch (FileNotFoundException | SSLException e) {
234+
logger.error(
235+
"initSslContext failed, caCert: {}, sslCert: {}, sslKey: {}, error: {}, e: {}",
236+
configOption.getCryptoMaterialConfig().getCaCertPath(),
237+
configOption.getCryptoMaterialConfig().getSdkCertPath(),
238+
configOption.getCryptoMaterialConfig().getSdkPrivateKeyPath(),
239+
e.getMessage(),
240+
e);
234241
throw new NetworkException(
235242
"SSL context init failed, please make sure your cert and key files are properly configured. error info: "
236243
+ e.getMessage(),
237244
NetworkException.INIT_CONTEXT_FAILED);
238245
} catch (IllegalArgumentException e) {
246+
logger.error("initSslContext failed, error: {}, e: {}", e.getMessage(), e);
239247
throw new NetworkException(
240248
"SSL context init failed, error info: " + e.getMessage(),
241249
NetworkException.INIT_CONTEXT_FAILED);
@@ -273,6 +281,15 @@ private SslContext initSMSslContext(ConfigOption configOption) throws NetworkExc
273281
| NoSuchAlgorithmException
274282
| InvalidKeySpecException
275283
| NoSuchProviderException e) {
284+
logger.error(
285+
"initSMSslContext failed, caCert:{}, sslCert: {}, sslKey: {}, enCert: {}, enKey: {}, error: {}, e: {}",
286+
configOption.getCryptoMaterialConfig().getCaCertPath(),
287+
configOption.getCryptoMaterialConfig().getSdkCertPath(),
288+
configOption.getCryptoMaterialConfig().getSdkPrivateKeyPath(),
289+
configOption.getCryptoMaterialConfig().getEnSSLCertPath(),
290+
configOption.getCryptoMaterialConfig().getEnSSLPrivateKeyPath(),
291+
e.getMessage(),
292+
e);
276293
throw new NetworkException(
277294
"SSL context init failed, please make sure your cert and key files are properly configured. error info: "
278295
+ e.getMessage(),
@@ -356,7 +373,7 @@ private boolean checkConnectionResult(
356373
+ ":"
357374
+ connInfo.getPort()
358375
+ checkerMessage;
359-
logger.debug(sslHandshakeFailedMessage);
376+
logger.error(sslHandshakeFailedMessage);
360377
errorMessageList.add(
361378
new RetCode(
362379
NetworkException.SSL_HANDSHAKE_FAILED, sslHandshakeFailedMessage));
@@ -375,7 +392,7 @@ private boolean checkConnectionResult(
375392
+ ":"
376393
+ connInfo.getPort()
377394
+ checkerMessage;
378-
logger.debug(sslHandshakeFailedMessage);
395+
logger.error(sslHandshakeFailedMessage);
379396
errorMessageList.add(
380397
new RetCode(
381398
NetworkException.SSL_HANDSHAKE_FAILED, sslHandshakeFailedMessage));

sdk-crypto/src/main/java/org/fisco/bcos/sdk/crypto/CryptoSuite.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,15 @@ public CryptoKeyPair createKeyPair(KeyPair keyPair) {
189189
return this.cryptoKeyPair;
190190
}
191191

192+
public CryptoKeyPair createKeyPair(String hexedPrivateKey) {
193+
this.cryptoKeyPair = this.keyPairFactory.createKeyPair(hexedPrivateKey);
194+
this.cryptoKeyPair.setConfig(config);
195+
return this.cryptoKeyPair;
196+
}
197+
192198
public void setCryptoKeyPair(CryptoKeyPair cryptoKeyPair) {
193199
this.cryptoKeyPair = cryptoKeyPair;
200+
this.cryptoKeyPair.setConfig(config);
194201
}
195202

196203
public CryptoKeyPair getCryptoKeyPair() {

0 commit comments

Comments
 (0)