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

Community #772

Open
wants to merge 33 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0568a0e
修改TransService,支持在constant关键 字下可以使用msg.sender对合约进行调
Apr 1, 2022
ed4af9f
修改TransService,支持在constant关键 字下可以使用msg.sender对合约进行调
Apr 1, 2022
7427eec
Merge pull request #735 from hhyyy9/fix_view_msgsender
CodingCattwo Apr 1, 2022
9ecb582
新增16进制私钥转10进制私钥的tool接口
gaoxuliang Apr 13, 2022
66e013a
optimize community constant tx random user or targe user bug
CodingCattwo Apr 18, 2022
9f0a08d
Update ToolController.java
gaoxuliang Apr 18, 2022
cedd061
Merge pull request #745 from CN-GaoXuLiang/community
CodingCattwo Apr 18, 2022
78f10aa
fix [#744]
JacksonRGB May 13, 2022
4290d60
Merge pull request #768 from minchenzz/community
CodingCattwo May 16, 2022
19e2c12
校验int/uint/uint256参数格式的正则表达式(当前错误代码为1-9),支持输入参数为0,即支持0-9的数字
Skkypy May 25, 2022
fbad4cc
Merge pull request #774 from Skkypy/master
CodingCattwo Jun 8, 2022
37ff005
WeBASE Task 2: struct Tuple类型入参增加提示语
Skkypy Aug 24, 2022
283b4a6
Task 任务3|脚本监控WeBase一键部署下各子系统正常服务
MaiLiJian-CN Aug 28, 2022
12145c9
Merge pull request #792 from Skkypy/community
CodingCattwo Oct 12, 2022
b901929
Merge pull request #813 from WeBankBlockchain/master
CodingCattwo Oct 12, 2022
f2c3a1c
Add files via upload
carpONE Oct 12, 2022
667235d
Merge pull request #797 from MaiLiJian-CN/community
CodingCattwo Oct 13, 2022
092e65b
Merge pull request #815 from carpONE/carpONE-task11
CodingCattwo Oct 17, 2022
ac39e51
Update CRUDParseUtils.java
idefa Oct 21, 2022
ac352f3
Merge pull request #818 from idefa/master
CodingCattwo Oct 24, 2022
efc6fb1
Merge pull request #842 from WeBankBlockchain/dev
CodingCattwo Apr 18, 2023
45a05f8
1.5.5
CodingCattwo Apr 18, 2023
b9267e7
Merge pull request #845 from WeBankBlockchain/dev
CodingCattwo Apr 19, 2023
235826f
Merge branch 'community' into merge0427
CodingCattwo Apr 27, 2023
2b6170a
Merge pull request #847 from WeBankBlockchain/merge0427
CodingCattwo Apr 27, 2023
e5df7e1
TASK 1 工具合约-Crypto合约详细使用
hior-y May 5, 2023
95f4a8c
Merge pull request #1 from hior-y/hior-y-upload-1
hior-y May 5, 2023
af787e7
fix pure in v0.6 above version
CodingCattwo May 5, 2023
495ddb5
fix tx constant of pure in 0.6 above
CodingCattwo May 8, 2023
e3899a3
Merge pull request #850 from CodingCattwo/dev155
CodingCattwo May 8, 2023
9803585
task17:新增动态更新P2P连接接口(包括add/erase/query三类)
WangDeheng-GDUFS Aug 23, 2023
355d84f
Merge pull request #867 from WangDeheng-GDUFS/master
CodingCattwo Sep 25, 2023
57dd069
Merge pull request #848 from hior-y/community
CodingCattwo Sep 25, 2023
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 Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### v1.5.4(2023-03-09)
### v1.5.5(2023-04-17)

**Fix**
- 支持合约函数复杂参数如Struct类型的入参与返回值,部署合约与发交易相关接口中`funcParam`类型从`List<Object>`改为`List<String>`
Expand Down
98 changes: 98 additions & 0 deletions WeBase-Listen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash
#获取webase系统路径
wb_path=$(pwd) #默认脚本与WeBase子系统处于同级目录,如有不同,自行修改
port=0
web_Port=5000 #默认5000

function webase_front(){
echo "check webase-front..." #在同级目录下查找webase-front文件夹
wabse_front_path=$(find $wb_path -name 'webase-front' -type d)
cd $wabse_front_path #进入WeBase-Front目录
status="$(bash status.sh)" #运行状态脚本
if [[ $status == *"running"* ]]
then
msg=`echo ${status#*Port}`
port=`echo ${msg%%i*}` #进行字符串截取获得端口(默认5002)
fi

port_msg=`lsof -i:$port` #lsof -i:port 查看端口连接
if [[ $port_msg == *"LISTEN"* ]] #判断端口是否被监听,是则正常运行,否则运行有误
then #后续两个子系统方法大致相同
echo "WeBase-Front is Successful"
else
echo "WeBase-Front is Fail"
return
fi
echo -e "Check webase-front finish\n"
}

function webase_node_mgr(){
#查找webase-node-mgr文件夹
echo "check webase-node-mgr..."
webase_node_mgr_path=$(find $wb_path -name 'webase-node-mgr' -type d)
cd $webase_node_mgr_path
status=$(bash status.sh)
if [[ $status == *"running"* ]]
then
msg=`echo ${status#*Port}`
port=`echo ${msg%%i*}` #获得端口
fi
port_msg=`lsof -i:$port`
if [[ $port_msg == *"LISTEN"* ]]
then
echo "WeBase-Node-Mgr is Successful"
else
echo "WeBase-Node-Mgr is Fail"
return
fi
echo -e "Check WeBase-Node-Mgr finish\n"
}

function webase_sign(){
#查找webase_sign文件夹
echo "check webase_sign..."
webase_sign_path=$(find $wb_path -name 'webase-sign' -type d)
cd $webase_sign_path
status=$(bash status.sh)
if [[ $status == *"running"* ]]
then
msg=`echo ${status#*Port}`
port=`echo ${msg%%i*}` #获得端口
else
echo "no running"
fi

port_msg=`lsof -i:$port`
if [[ $port_msg == *"LISTEN"* ]]
then
echo "WeBase-Sign is Successful"
else
echo "WeBase-Sign is Fail"
fi
echo -e "Check WeBase-Sign finish\n"
}
function webase_web(){
echo "check webase_web..."
nginx_conf=$wb_path/comm/nginx.conf #获取nginx.conf的工作路径
nginx_msg="`ps -ef |grep nginx`" #ps(英文全拼:process status)命令用于显示当前进程的状态 ps -ef -e显示所有进程,-f全格式。

if [[ $nginx_msg == *$nginx_conf* ]] #进行匹配查看,nginx服务有无使用webase-web自带的nginx配置
then
echo "WeBase-Web is Successful"
else
echo "WeBase-Web is Fail"
fi
echo -e "Check WeBase-Web finish\n"
}
# WeBase-Front子系统测试
sleep 3
webase_front
# WeBase-Node-Msg子系统测试
sleep 3
webase_node_mgr
# WeBase-Sign子系统测试
sleep 3
webase_sign
# WeBase-Web子系统测试
sleep 3
webase_web
64 changes: 64 additions & 0 deletions WeBase-Listen.sh 文件详解.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# WeBase-Listen.sh 文件详解

------

作者:深职院-麦立健

ps:shell语言的编写,平时不常接触,有不足,请包涵,欢迎各位指出问题。

获取WeBase子系统的同级路径

```shell
wb_path=$(pwd) #默认脚本与WeBase子系统处于同级目录,如有不同,自行修改
port=0
web_Port=5000 #默认5000
```

Webase_Front函数的思路是去获取子系统下的status.sh函数,判断其是否有正常启动,获得输出字符,经过字符串的截取获得WeBase-Front启动时的浏览器端口,通过losf -i:端口,进行判断是否有在监听状态。

```shell
function webase_front(){
echo "check webase-front..." #在同级目录下查找webase-front文件夹
wabse_front_path=$(find $wb_path -name 'webase-front' -type d)
cd $wabse_front_path #进入WeBase-Front目录
status="$(bash status.sh)" #运行状态脚本
if [[ $status == *"running"* ]]
then
msg=`echo ${status#*Port}`
port=`echo ${msg%%i*}` #进行字符串截取获得端口(默认5002)
fi

port_msg=`lsof -i:$port` #lsof -i:port 查看端口连接
if [[ $port_msg == *"LISTEN"* ]] #判断端口是否被监听,是则正常运行,否则运行有误
then #后续两个子系统方法大致相同
echo "WeBase-Front is Successful"
else
echo "WeBase-Front is Fail"
return
fi
echo -e "Check webase-front finish\n"
}
```

WeBase-Node-Msg和WeBase-Sign方法同上,不再赘述。

------

WeBase-Web本身主要是存放静态页面等资源,所以不存在start.sh和status.sh等脚本文件,而log日志文件也记录的是浏览器的请求信息,对于判断意义不大,所以用监听nginx服务的方法。通过获取WeBase一键部署时的nginx配置文件路径,再查看nginx服务,通过字符串比较来判断nginx服务有无采用WeBase一键部署的配置文件,有则说明WeBase-Web服务成功跑起来了~

```shell
function webase_web(){
echo "check webase_web..."
nginx_conf=$wb_path/comm/nginx.conf #获取nginx.conf的工作路径
nginx_msg="`ps -ef |grep nginx`" #ps(英文全拼:process status)命令用于显示当前进程的状态 ps -ef -e显示所有进程,-f全格式。

if [[ $nginx_msg == *$nginx_conf* ]] #进行匹配查看,nginx服务有无使用webase-web自带的nginx配置
then
echo "WeBase-Web is Successful"
else
echo "WeBase-Web is Fail"
fi
echo -e "Check WeBase-Web finish\n"
}
```

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public class CRUDParseUtils {
private static final Logger logger = LoggerFactory.getLogger(CRUDParseUtils.class);
public static final String PRIMARY_KEY = "primary key";

private static String unescape(String name){
if(name.contains("`")){
return name.replace("`","");
}
return name;
}

public static void parseCreateTable(String sql, Table table)
throws JSQLParserException, FrontException {
Statement statement = CCJSqlParserUtil.parse(sql);
Expand All @@ -71,8 +78,8 @@ public static void parseCreateTable(String sql, Table table)
Index index = indexes.get(0);
String type = index.getType().toLowerCase();
if (PRIMARY_KEY.equals(type)) {
table.setKey(index.getColumnsNames().get(0));
table.setKeyFieldName(index.getColumnsNames().get(0));
table.setKey(unescape(index.getColumnsNames().get(0)));
table.setKeyFieldName(unescape(index.getColumnsNames().get(0)));
} else {
throw new FrontException(ConstantCode.SQL_ERROR,
"Please provide only one primary key for the table.");
Expand All @@ -96,7 +103,7 @@ public static void parseCreateTable(String sql, Table table)
}
} else {
keyFlag = true;
table.setKey(key);
table.setKey(unescape(key));
}
break;
}
Expand All @@ -109,16 +116,16 @@ public static void parseCreateTable(String sql, Table table)
List<String> fieldsList = new ArrayList<>();
for (int i = 0; i < columnDefinitions.size(); i++) {
String columnName = columnDefinitions.get(i).getColumnName();
if (fieldsList.contains(columnName)) {
if (fieldsList.contains(unescape(columnName))) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Please provide the field '" + columnName + "' only once.");
"Please provide the field '" + columnName + "' only once.");
} else {
fieldsList.add(columnName);
fieldsList.add(unescape(columnName));
}
}
if (!fieldsList.contains(table.getKey())) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Please provide the field '" + table.getKey() + "' in column definition.");
"Please provide the field '" + table.getKey() + "' in column definition.");
} else {
fieldsList.remove(table.getKey());
}
Expand Down Expand Up @@ -172,7 +179,7 @@ public static boolean parseInsert(
}
if (expectedValueNum != columns.size()) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Column count doesn't match value count, fields size: "
"Column count doesn't match value count, fields size: "
+ valueFields.length
+ ", provided field value size: "
+ columns.size()
Expand All @@ -182,11 +189,11 @@ public static boolean parseInsert(
List<String> columnNames = new ArrayList<>();
for (Column column : columns) {
String columnName = trimQuotes(column.toString());
if (columnNames.contains(columnName)) {
if (columnNames.contains(unescape(columnName))) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Please provide the field '" + columnName + "' only once.");
"Please provide the field '" + columnName + "' only once.");
} else {
columnNames.add(columnName);
columnNames.add(unescape(columnName));
}
}
for (int i = 0; i < columnNames.size(); i++) {
Expand All @@ -197,7 +204,7 @@ public static boolean parseInsert(
String keyField = tableDesc.get(PrecompiledConstant.KEY_FIELD_NAME);
if (expectedValueNum != itemArr.length) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Column count doesn't match value count, fields size: "
"Column count doesn't match value count, fields size: "
+ valueFields.length
+ ", provided field value size: "
+ itemArr.length
Expand Down Expand Up @@ -266,10 +273,10 @@ public static void parseSelect(
if (expression instanceof Function) {
Function func = (Function) expression;
throw new FrontException(ConstantCode.SQL_ERROR,
"The " + func.getName() + " function is not supported.");
"The " + func.getName() + " function is not supported.");
}
}
selectColumns.add(item.toString());
selectColumns.add(unescape(item.toString()));
}
}

Expand Down Expand Up @@ -351,7 +358,7 @@ public static void parseUpdate(String sql, Table table, Entry entry, Condition c
}
for (int i = 0; i < columns.size(); i++) {
entry.getFieldNameToValue()
.put(trimQuotes(columns.get(i).toString()), trimQuotes(values[i]));
.put(trimQuotes(unescape(columns.get(i).toString())), trimQuotes(values[i]));
}

// parse where clause
Expand Down Expand Up @@ -398,8 +405,8 @@ private static void parseLimit(Condition condition, Limit limit)
}
} catch (NumberFormatException e) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Please provide limit parameters by non-negative integer mode, "
+ PrecompiledUtils.NonNegativeIntegerRange
"Please provide limit parameters by non-negative integer mode, "
+ "from 0 to 2147483647"
+ ".");
}
}
Expand All @@ -415,7 +422,7 @@ private static Condition getWhereClause(Expression expr, Condition condition)
@Override
protected void visitBinaryExpression(BinaryExpression expr) {
if (expr instanceof ComparisonOperator) {
String key = trimQuotes(expr.getLeftExpression().toString());
String key = unescape(trimQuotes(expr.getLeftExpression().toString()));
if (keySet.contains(key)) {
conflictKeys.add(key);
}
Expand Down Expand Up @@ -456,12 +463,12 @@ protected void visitBinaryExpression(BinaryExpression expr) {
});
if (conflictKeys.size() > 0) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Wrong condition! There cannot be the same field in the same condition! The conflicting field is: "
"Wrong condition! There cannot be the same field in the same condition! The conflicting field is: "
+ conflictKeys.toString());
}
if (unsupportedConditions.size() > 0) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Wrong condition! Find unsupported conditions! message: "
"Wrong condition! Find unsupported conditions! message: "
+ unsupportedConditions.toString());
}
return condition;
Expand All @@ -482,7 +489,7 @@ public static void invalidSymbol(String sql) throws FrontException {

public static boolean checkTableExistence(List<Map<String, String>> descTable) {
if (descTable.size() == 0
|| descTable.get(0).get(PrecompiledConstant.KEY_FIELD_NAME).equals("")) {
|| descTable.get(0).get(PrecompiledConstant.KEY_FIELD_NAME).equals("")) {
// System.out.println("The table \"" + tableName + "\" doesn't exist!");
return false;
}
Expand Down Expand Up @@ -563,17 +570,17 @@ public static void handleKey(Table table, Condition condition) {
Map<ConditionOperator, String> keyMap = condition.getConditions().get(keyName);
if (keyMap == null) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Please provide a equal condition for the key field '"
+ keyName
+ "' in where clause.");
"Please provide a equal condition for the key field '"
+ keyName
+ "' in where clause.");
} else {
Set<ConditionOperator> keySet = keyMap.keySet();
for (ConditionOperator enumOP : keySet) {
if (enumOP != ConditionOperator.eq) {
throw new FrontException(ConstantCode.SQL_ERROR,
"Please provide a equal condition for the key field '"
+ keyName
+ "' in where clause.");
"Please provide a equal condition for the key field '"
+ keyName
+ "' in where clause.");
} else {
keyValue = keyMap.get(enumOP);
}
Expand Down Expand Up @@ -601,7 +608,7 @@ public static List<Map<String, String>> filterSystemColum(List<Map<String, Strin
}

public static List<Map<String, String>> getSelectedColumn(
List<String> selectColumns, List<Map<String, String>> result) {
List<String> selectColumns, List<Map<String, String>> result) {
List<Map<String, String>> selectedResult = new ArrayList<>(result.size());
Map<String, String> selectedRecords;
for (Map<String, String> records : result) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/webank/webase/front/tool/ToolController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.validation.Valid;
import java.math.BigInteger;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.fisco.bcos.sdk.abi.ABICodec;
Expand Down Expand Up @@ -222,5 +223,14 @@ public RspSignData getSignedData(@Valid @RequestBody ReqSign reqSign) {
return new RspSignData(signatureData, cryptoSuite.cryptoTypeConfig);
}

@ApiOperation(value = "hex privateKey to decimal ", notes = "get decimal PrivateKey")
@ApiImplicitParam(name = "hexPrivateKey", value = "hex private key", dataType = "String")
@GetMapping("/hexKey2Dec")
public String hexKey2Dec(@RequestParam String hexPrivateKey) {
if (hexPrivateKey.startsWith("0x")){
hexPrivateKey = hexPrivateKey.substring(2);
}
return new BigInteger(hexPrivateKey,16).toString();
}

}
Loading