Skip to content

Commit

Permalink
Merge pull request #143 from ywy2090/release-1.0.4
Browse files Browse the repository at this point in the history
merge release1.0.4
  • Loading branch information
bxq2011hust authored Jul 5, 2019
2 parents 78a64eb + d9b19e9 commit 007e9cc
Show file tree
Hide file tree
Showing 22 changed files with 513 additions and 192 deletions.
12 changes: 12 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
### v1.0.4

(2019-07-05)

* 增加

1. 添加交易解析功能:`call``callCNS`支持解析`output``event log`
`getTransactionByHash``getTransactionByBlockHashAndIndex``getTransactionByBlockHashAndIndex` 支持解析`input`
`getTransactionReceipt`支持解析`input``output``event log`
2. 去除无用的jar包依赖


### v1.0.3

(2019-05-28)
Expand Down
21 changes: 19 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ check.dependsOn.remove(verifyGoogleJavaFormat)
// In this section you declare the dependencies for your production and test code
dependencies {
// compile group: "org.fisco-bcos", name: "web3sdk", version: "2.0.31-SNAPSHOT", changing: true
compile group: 'org.fisco-bcos', name: 'web3sdk', version: '2.0.3'
compile group: 'org.fisco-bcos', name: 'web3sdk', version: '2.0.4'
compile group: 'org.slf4j', name:'slf4j-log4j12', version:'1.7.25'
compile group: 'org.jline', name: 'jline', version: '3.11.0'
// compile group: 'org.jline', name: 'jline', version: '3.11.0'
compile files('lib/jline-3.11.1-SNAPSHOT.jar')
compile group: 'io.bretty', name: 'console-table-builder', version: '1.2'
compile group: 'com.github.jsqlparser', name: 'jsqlparser', version: '2.0'
testCompile group: 'junit', name: 'junit', version: '4.1'
Expand All @@ -39,6 +40,22 @@ dependencies {
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

configurations {
all*.exclude group: 'org.java-websocket', module: 'Java-WebSocket'
all*.exclude group: 'org.antlr', module: '*'
all*.exclude group: 'de.vandermeer', module: '*'
all*.exclude group: 'net.bytebuddy', module: 'byte-buddy'
all*.exclude group: 'commons-configuration', module: 'commons-configuration'
all*.exclude group: 'org.apache.commons', module: 'commons-lang'
all*.exclude group: 'com.alibaba', module: 'druid'
all*.exclude group: 'com.google.guava', module: 'guava'
all*.exclude group: 'org.apache.httpcomponents', module: 'httpclient'
all*.exclude group: 'org.mockito', module: 'mockito-core'
all*.exclude group: 'io.reactivex', module: 'rxjava'
// all*.exclude group: 'org.ethereum', module: 'solcJ-all'
}

sourceSets {
main {
java {
Expand Down
1 change: 1 addition & 0 deletions contracts/solidity/Table.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ contract Entry {
function getAddress(string) public constant returns(address);
function getBytes64(string) public constant returns(byte[64]);
function getBytes32(string) public constant returns(bytes32);
function getString(string) public constant returns(string);

function set(string, int) public;
function set(string, string) public;
Expand Down
13 changes: 7 additions & 6 deletions contracts/solidity/TableTest.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pragma solidity ^0.4.24;

pragma experimental ABIEncoderV2;
import "./Table.sol";


contract TableTest {
event CreateResult(int count);
event InsertResult(int count);
Expand All @@ -19,23 +20,23 @@ contract TableTest {
}

//select records
function select(string name) public constant returns(bytes32[], int[], bytes32[]){
function select(string name) public constant returns(string[], int[], string[]){
TableFactory tf = TableFactory(0x1001);
Table table = tf.openTable("t_test");

Condition condition = table.newCondition();

Entries entries = table.select(name, condition);
bytes32[] memory user_name_bytes_list = new bytes32[](uint256(entries.size()));
string[] memory user_name_bytes_list = new string[](uint256(entries.size()));
int[] memory item_id_list = new int[](uint256(entries.size()));
bytes32[] memory item_name_bytes_list = new bytes32[](uint256(entries.size()));
string[] memory item_name_bytes_list = new string[](uint256(entries.size()));

for(int i=0; i<entries.size(); ++i) {
Entry entry = entries.get(i);

user_name_bytes_list[uint256(i)] = entry.getBytes32("name");
user_name_bytes_list[uint256(i)] = entry.getString("name");
item_id_list[uint256(i)] = entry.getInt("item_id");
item_name_bytes_list[uint256(i)] = entry.getBytes32("item_name");
item_name_bytes_list[uint256(i)] = entry.getString("item_name");
}

return (user_name_bytes_list, item_id_list, item_name_bytes_list);
Expand Down
Binary file added lib/jline-3.11.1-SNAPSHOT.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion release_note.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.3
v1.0.4
23 changes: 21 additions & 2 deletions src/main/java/console/ConsoleClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
import console.web3j.Web3jFace;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Scanner;
import org.fisco.bcos.web3j.protocol.channel.ResponseExcepiton;
import org.fisco.bcos.web3j.protocol.exceptions.MessageDecodingException;
import org.jline.keymap.KeyMap;
import org.jline.reader.Binding;
import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader;
import org.jline.reader.Reference;
import org.jline.reader.UserInterruptException;

public class ConsoleClient {
Expand All @@ -24,10 +28,13 @@ public class ConsoleClient {
private static PermissionFace permissionFace;
private static ContractFace contractFace;

public static int INPUT_FLAG = 0;

@SuppressWarnings("resource")
public static void main(String[] args) {

LineReader lineReader = null;
Scanner sc = null;
ConsoleInitializer consoleInitializer = null;
try {
consoleInitializer = new ConsoleInitializer();
Expand All @@ -37,6 +44,10 @@ public static void main(String[] args) {
permissionFace = consoleInitializer.getPermissionFace();
contractFace = consoleInitializer.getContractFace();
lineReader = JlineUtils.getLineReader();
sc = new Scanner(System.in);
KeyMap<Binding> keymap = lineReader.getKeyMaps().get(LineReader.MAIN);
keymap.bind(new Reference("beginning-of-line"), "\033[1~");
keymap.bind(new Reference("end-of-line"), "\033[4~");
} catch (Exception e) {
System.out.println(e.getMessage());
return;
Expand All @@ -51,8 +62,16 @@ public static void main(String[] args) {
System.out.println("Console can not read commands.");
break;
}
String request =
lineReader.readLine("[group:" + consoleInitializer.getGroupID() + "]> ");
String request = "";
if (INPUT_FLAG == 0) {
request =
lineReader.readLine(
"[group:" + consoleInitializer.getGroupID() + "]> ");
} else {
System.out.print("[group:" + consoleInitializer.getGroupID() + "]> ");
sc = new Scanner(System.in);
request = sc.nextLine();
}
String[] params = null;
params = ConsoleUtils.tokenizeCommand(request);
if (params.length < 1) {
Expand Down
115 changes: 73 additions & 42 deletions src/main/java/console/ConsoleInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,58 +69,36 @@ public void init(String[] args)
useDefaultCredentials();
break;
case 1: // bash start.sh groupID
groupID = setGroupID(args[0]);
if ("-l".equals(args[0])) { // input by scanner for log
ConsoleClient.INPUT_FLAG = 1;
} else {
groupID = setGroupID(args[0]);
}
useDefaultCredentials();
break;
case 3: // ./start.sh groupID -pem pemName
if ("-pem".equals(args[1])) {
case 2: // bash start.sh groupID -l
if ("-l".equals(args[1])) { // input by scanner for log
ConsoleClient.INPUT_FLAG = 1;
groupID = setGroupID(args[0]);
String pemName = args[2];
pemName = handlPemFileName(pemName);
PEMManager pem = new PEMManager();
pem.setPemFile("classpath:" + pemName);
try {
pem.load();
} catch (Exception e) {
System.out.println(e.getMessage());
close();
}
ECKeyPair keyPair = pem.getECKeyPair();
credentials = Credentials.create(keyPair);
} else if ("-p12".equals(args[1])) {
groupID = setGroupID(args[0]);
String p12Name = args[2];
p12Name = handleP12FileName(p12Name);
System.out.print("Enter Export Password:");
Console cons = System.console();
char[] passwd = cons.readPassword();
String password = new String(passwd);
P12Manager p12Manager = new P12Manager();
p12Manager.setPassword(password);
p12Manager.setP12File("classpath:" + p12Name);
try {
p12Manager.load();
} catch (Exception e) {
System.out.println(e.getMessage());
close();
}
ECKeyPair keyPair;
try {
keyPair = p12Manager.getECKeyPair(password);
credentials = Credentials.create(keyPair);
} catch (Exception e) {
System.out.println("The name for p12 account is error.");
close();
}
useDefaultCredentials();
} else {
HelpInfo.startHelp();
close();
}
break;
case 3: // ./start.sh groupID -pem pemName
handleAccountParam(args);
break;
default:
HelpInfo.startHelp();
close();
if (args.length == 4 && "-l".equals(args[3])) {
handleAccountParam(args);
ConsoleClient.INPUT_FLAG = 1;
} else {
HelpInfo.startHelp();
close();
}
}

if (credentials == null) {
System.out.println("Please provide a valid account.");
close();
Expand Down Expand Up @@ -185,6 +163,59 @@ public void init(String[] args)
}
}

private void handleAccountParam(String[] args)
throws UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException,
InvalidKeySpecException, NoSuchProviderException,
InvalidAlgorithmParameterException {
if ("-pem".equals(args[1])) {
groupID = setGroupID(args[0]);
String pemName = args[2];
pemName = handlPemFileName(pemName);
PEMManager pem = new PEMManager();
pem.setPemFile("classpath:" + pemName);
try {
pem.load();
} catch (Exception e) {
System.out.println(e.getMessage());
close();
}
ECKeyPair keyPair = pem.getECKeyPair();
credentials = Credentials.create(keyPair);
} else if ("-p12".equals(args[1])) {
groupID = setGroupID(args[0]);
String p12Name = args[2];
p12Name = handleP12FileName(p12Name);
System.out.print("Enter Export Password:");
Console cons = System.console();
char[] passwd = cons.readPassword();
String password = new String(passwd);
P12Manager p12Manager = new P12Manager();
p12Manager.setPassword(password);
p12Manager.setP12File("classpath:" + p12Name);
try {
p12Manager.load();
} catch (Exception e) {
System.out.println(e.getMessage());
close();
}
ECKeyPair keyPair;
try {
keyPair = p12Manager.getECKeyPair();
credentials = Credentials.create(keyPair);
} catch (Exception e) {
System.out.println("The name for p12 account is error.");
close();
}
} else if ("-l".equals(args[1])) {
groupID = setGroupID(args[0]);
ConsoleClient.INPUT_FLAG = 1;
useDefaultCredentials();
} else {
HelpInfo.startHelp();
close();
}
}

private String handlPemFileName(String pemName) {
if (pemName.startsWith(ACCOUNT_DIR1)) {
pemName = pemName.substring(ACCOUNT_DIR1.length());
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/console/common/AbiAndBin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package console.common;

public class AbiAndBin {
private String abi;
private String bin;

public String getAbi() {
return abi;
}

public void setAbi(String abi) {
this.abi = abi;
}

public String getBin() {
return bin;
}

public void setBin(String bin) {
this.bin = bin;
}
}
6 changes: 1 addition & 5 deletions src/main/java/console/common/CRUDParseUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,7 @@ public static void checkUserTableParam(Entry entry, Table descTable)
} else {
if (fieldsMap.get(key).length() > Common.USER_TABLE_FIELD_VALUE_MAX_LENGTH) {
throw new ConsoleMessageException(
"The table field '"
+ key
+ "' value length is greater than "
+ Common.USER_TABLE_FIELD_VALUE_MAX_LENGTH
+ ".");
"The table field '" + key + "' value length is greater than 16M - 1.");
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/console/common/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class Common {
public static final String DeployLogntegerRange = "from 1 to 100";
public static final String NodeIdLength = "128";
public static final String TxGasLimitRange = "from 100000 to 2147483647";
public static final String EMPTY_CONTRACT_ADDRESS =
"0x0000000000000000000000000000000000000000";
public static final String EMPTY_OUTPUT = "0x";
public static final int TxGasLimitMin = 10000;

public static int PermissionCode = 0;
Expand All @@ -26,5 +29,5 @@ public class Common {
public static int SYS_TABLE_VALUE_FIELD_MAX_LENGTH = 1024;
public static int USER_TABLE_KEY_VALUE_MAX_LENGTH = 255;
public static int USER_TABLE_FIELD_NAME_MAX_LENGTH = 64;
public static int USER_TABLE_FIELD_VALUE_MAX_LENGTH = 65535;
public static int USER_TABLE_FIELD_VALUE_MAX_LENGTH = 16 * 1024 * 1024 - 1;
}
2 changes: 1 addition & 1 deletion src/main/java/console/common/ConsoleVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class ConsoleVersion {

public static final String Version = "1.0.3";
public static final String Version = "1.0.4";

public static void main(String[] args) {
System.out.println("console version: " + Version);
Expand Down
Loading

0 comments on commit 007e9cc

Please sign in to comment.