Skip to content

Commit

Permalink
Merge pull request #270 from FISCO-BCOS/release-1.0.10
Browse files Browse the repository at this point in the history
merge release 1.0.10 into master
  • Loading branch information
bxq2011hust authored Jun 9, 2020
2 parents 48897b9 + 97fae41 commit 751aacb
Show file tree
Hide file tree
Showing 18 changed files with 779 additions and 138 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ 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.4.0'
compile group: 'org.fisco-bcos', name: 'web3sdk', version: '2.5.0-05280-SNAPSHOT'
compile group: 'commons-codec', name:'commons-codec', version:'1.10'
compile group: 'org.slf4j', name:'slf4j-log4j12', version:'1.7.25'
compile group: 'org.jline', name: 'jline', version: '3.12.0'
compile group: 'io.bretty', name: 'console-table-builder', version: '1.2'
compile group: 'com.github.jsqlparser', name: 'jsqlparser', version: '2.0'
testCompile 'com.github.stefanbirkner:system-rules:1.18.0'
testCompile group: 'junit', name: 'junit', version: '4.1'
}

Expand All @@ -52,6 +53,7 @@ configurations {
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.projectlombok', module: 'lombok'
// all*.exclude group: 'org.ethereum', module: 'solcJ-all'
}

Expand Down
54 changes: 45 additions & 9 deletions src/main/java/console/ConsoleClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ public static void main(String[] args) {
case "getTransactionReceipt":
web3jFace.getTransactionReceipt(params);
break;
case "getTransactionByHashWithProof":
web3jFace.getTransactionByHashWithProof(params);
break;
case "getTransactionReceiptByHashWithProof":
web3jFace.getTransactionReceiptByHashWithProof(params);
break;
case "getPendingTransactions":
web3jFace.getPendingTransactions(params);
break;
Expand Down Expand Up @@ -247,15 +253,6 @@ public static void main(String[] args) {
case "listDeployAndCreateManager":
permissionFace.listDeployAndCreateManager(params);
break;
case "grantPermissionManager":
permissionFace.grantPermissionManager(params);
break;
case "revokePermissionManager":
permissionFace.revokePermissionManager(params);
break;
case "listPermissionManager":
permissionFace.listPermissionManager(params);
break;
case "grantNodeManager":
permissionFace.grantNodeManager(params);
break;
Expand Down Expand Up @@ -307,6 +304,45 @@ public static void main(String[] args) {
case "listContractStatusManager":
precompiledFace.listContractStatusManager(params);
break;
case "grantCommitteeMember":
permissionFace.grantCommitteeMember(params);
break;
case "revokeCommitteeMember":
permissionFace.revokeCommitteeMember(params);
break;
case "listCommitteeMembers":
permissionFace.listCommitteeMembers(params);
break;
case "grantOperator":
permissionFace.grantOperator(params);
break;
case "listOperators":
permissionFace.listOperators(params);
break;
case "revokeOperator":
permissionFace.revokeOperator(params);
break;
case "updateThreshold":
permissionFace.updateThreshold(params);
break;
case "updateCommitteeMemberWeight":
permissionFace.updateCommitteeMemberWeight(params);
break;
case "queryThreshold":
permissionFace.queryThreshold(params);
break;
case "queryCommitteeMemberWeight":
permissionFace.queryCommitteeMemberWeight(params);
break;
case "freezeAccount":
permissionFace.freezeAccount(params);
break;
case "unfreezeAccount":
permissionFace.unfreezeAccount(params);
break;
case "getAccountStatus":
permissionFace.getAccountStatus(params);
break;
default:
System.out.println(
"Undefined command: \"" + params[0] + "\". Try \"help\".\n");
Expand Down
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.9";
public static final String Version = "1.0.10";

public static void main(String[] args) {
System.out.println("console version: " + Version);
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/console/common/ContractClassFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ public class ContractClassFactory {
public static final String PACKAGE_NAME = "temp";
public static final String TAR_GET_CLASSPATH = "contracts/console/java/classes/";
public static final String SOL_POSTFIX = ".sol";
private static URLClassLoader classLoader;

public static void initClassLoad() throws MalformedURLException {
public static URLClassLoader initClassLoad() throws MalformedURLException {
File clazzPath = new File(TAR_GET_CLASSPATH);
if (!clazzPath.exists()) {
clazzPath.mkdirs();
}

URL[] urls = new URL[1];
urls[0] = clazzPath.toURI().toURL();
classLoader = new URLClassLoader(urls);

URLClassLoader classLoader = new URLClassLoader(urls);
return classLoader;
}

public static Class<?> compileContract(String name) throws Exception {
Expand All @@ -76,7 +77,7 @@ public static Class<?> compileContract(String name) throws Exception {
}
String contractName = PACKAGE_NAME + "." + name;
try {
return getContractClass(contractName);
return getContractClass2(contractName);
} catch (Exception e) {
throw new Exception(
"There is no " + name + ".class" + " in the directory of java/classes/temp");
Expand Down Expand Up @@ -179,6 +180,7 @@ public boolean accept(File pathname) {
className = className.replace(File.separatorChar, '.');

if (contractName.equals(className)) {
URLClassLoader classLoader = initClassLoad();
return Class.forName(className, true, classLoader);
}
}
Expand All @@ -189,6 +191,11 @@ public boolean accept(File pathname) {
return Class.forName(contractName);
}

public static Class<?> getContractClass2(String contractName) throws ClassNotFoundException {
ContractClassLoader contractClassLoader = new ContractClassLoader(TAR_GET_CLASSPATH);
return contractClassLoader.loadClass(contractName);
}

public static RemoteCall<?> handleDeployParameters(
Web3j web3j,
Credentials credentials,
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/console/common/ContractClassLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package console.common;

import java.io.File;
import java.nio.file.Files;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ContractClassLoader extends ClassLoader {

private static final Logger logger = LoggerFactory.getLogger(ContractClassLoader.class);

private String classPath;

public ContractClassLoader(String classPath) {
this.classPath = classPath;
}

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
try {
String fullName = classPath + "/" + name.replaceAll("\\.", "/") + ".class";
logger.debug("name: {}, fullName: {}", name, fullName);
File file = new File(fullName);
byte[] data = Files.readAllBytes(file.toPath());
return defineClass(name, data, 0, data.length);
} catch (Exception e) {
logger.warn("e: {}", e);
throw new ClassNotFoundException("Cannot findClass " + name, e.getCause());
}
}
}
137 changes: 114 additions & 23 deletions src/main/java/console/common/HelpInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ public static void helpNoParams(String func) {
case "listDeployAndCreateManager":
listDeployAndCreateManagerHelp();
break;
case "listPermissionManager":
listPermissionManagerHelp();
break;
case "listNodeManager":
listNodeManagerHelp();
break;
Expand Down Expand Up @@ -113,6 +110,15 @@ public static void helpNoParams(String func) {
case "getContractStatus":
getContractStatusHelp();
break;
case "listCommitteeMembers":
listCommitteeMembersHelp();
break;
case "queryThreshold":
queryThresholdHelp();
break;
case "listOperators":
listOperatorsHelp();
break;
case "quit":
case "q":
quitHelp();
Expand Down Expand Up @@ -307,6 +313,22 @@ public static void getTransactionByBlockHashAndIndexHelp() {
System.out.println();
}

public static void getTransactionByHashWithProofHelp() {
System.out.println(
"Query information about the transaction and proof by transaction hash.");
System.out.println("Usage: getTransactionByHashWithProof transactionHash");
System.out.println("transactionHash -- 32 Bytes - The hash of a transaction.");
System.out.println();
}

public static void getTransactionReceiptByHashWithProofHelp() {
System.out.println(
"Query information about the transaction receipt and proof by transaction hash.");
System.out.println("Usage: getTransactionReceiptByHashWithProof transactionHash");
System.out.println("transactionHash -- 32 Bytes - The hash of a transaction.");
System.out.println();
}

public static void getTransactionByBlockNumberAndIndexHelp() {
System.out.println(
"Query information about a transaction by block number and transaction index position.");
Expand Down Expand Up @@ -482,26 +504,6 @@ public static void listDeployAndCreateManagerHelp() {
System.out.println();
}

public static void grantPermissionManagerHelp() {
System.out.println("Grant permission for permission configuration by address.");
System.out.println("Usage: grantPermissionManager address");
System.out.println("address -- 20 Bytes - The address of a tx.origin.");
System.out.println();
}

public static void revokePermissionManagerHelp() {
System.out.println("Revoke permission for permission configuration by address.");
System.out.println("Usage: revokePermissionManager address");
System.out.println("address -- 20 Bytes - The address of a tx.origin.");
System.out.println();
}

public static void listPermissionManagerHelp() {
System.out.println("Query permission information for permission configuration.");
System.out.println("Usage: listPermissionManager");
System.out.println();
}

public static void grantNodeManagerHelp() {
System.out.println("Grant permission for node configuration by address.");
System.out.println("Usage: grantNodeManager address");
Expand Down Expand Up @@ -585,6 +587,95 @@ public static void revokeContractWritePermissionHelp() {
System.out.println();
}

public static void listCommitteeMembersHelp() {
System.out.println("List committee members.");
System.out.println("Usage: listCommitteeMembers");
System.out.println();
}

public static void grantCommitteeMemberHelp() {
System.out.println("Grant committee member.");
System.out.println("Usage: grantCommitteeMember account");
System.out.println("account -- 20 Bytes - The address of a account.");
System.out.println();
}

public static void revokeCommitteeMemberHelp() {
System.out.println("Revoke committee member.");
System.out.println("Usage: revokeCommitteeMember account");
System.out.println("account -- 20 Bytes - The address of a account.");
System.out.println();
}

public static void queryCommitteeMemberWeightHelp() {
System.out.println("Query committee member weight.");
System.out.println("Usage: queryCommitteeMemberWeight account");
System.out.println("account -- 20 Bytes - The address of a account.");
System.out.println();
}

public static void updateCommitteeMemberWeightHelp() {
System.out.println("Update committee member weight.");
System.out.println("Usage: updateCommitteeMemberWeight account weight");
System.out.println("account -- 20 Bytes - The address of a account.");
System.out.println("weight -- int - The weight of the account.");
System.out.println();
}

public static void queryThresholdHelp() {
System.out.println("Query committee threshold.");
System.out.println("Usage: queryThreshold");
System.out.println();
}

public static void updateThresholdHelp() {
System.out.println("Update committee threshold.");
System.out.println("Usage: updateThreshold threshold");
System.out.println("threshold -- int - The threshold of the committee.");
System.out.println();
}

public static void listOperatorsHelp() {
System.out.println("List operator members.");
System.out.println("Usage: listOperators");
System.out.println();
}

public static void grantOperatorHelp() {
System.out.println("Grant operator.");
System.out.println("Usage: grantOperator account");
System.out.println("account -- 20 Bytes - The address of a account.");
System.out.println();
}

public static void revokeOperatorHelp() {
System.out.println("Revoke operator.");
System.out.println("Usage: revokeOperator account");
System.out.println("account -- 20 Bytes - The address of a account.");
System.out.println();
}

public static void freezeAccountHelp() {
System.out.println("Freeze account.");
System.out.println("Usage: freezeAccount account");
System.out.println("account -- 20 Bytes - The address of a account.");
System.out.println();
}

public static void unfreezeAccountHelp() {
System.out.println("Unfreeze account.");
System.out.println("Usage: unfreezeAccount account");
System.out.println("account -- 20 Bytes - The address of a account.");
System.out.println();
}

public static void getAccountStatusHelp() {
System.out.println("Account status.");
System.out.println("Usage: getAccountStatus account");
System.out.println("account -- 20 Bytes - The address of a account.");
System.out.println();
}

public static void setSystemConfigByKeyHelp() {
System.out.println("Set a system config.");
System.out.println("Usage: setSystemConfigByKey key value");
Expand Down
Loading

0 comments on commit 751aacb

Please sign in to comment.