|
56 | 56 | import org.tron.protos.contract.SmartContractOuterClass.SmartContract; |
57 | 57 | import org.tron.protos.Protocol.Transaction; |
58 | 58 | import org.tron.protos.Protocol.TransactionInfo; |
| 59 | +import org.tron.protos.contract.SmartContractOuterClass.SmartContractDataWrapper; |
59 | 60 | import org.tron.walletserver.WalletApi; |
60 | 61 |
|
61 | 62 |
|
@@ -108,6 +109,7 @@ public class Client { |
108 | 109 | "GetBrokerage", |
109 | 110 | "GetChainParameters", |
110 | 111 | "GetContract contractAddress", |
| 112 | + "GetContractInfo contractAddress", |
111 | 113 | "GetDelegatedResource", |
112 | 114 | "GetDelegatedResourceAccountIndex", |
113 | 115 | "GetDiversifier", |
@@ -237,6 +239,7 @@ public class Client { |
237 | 239 | "GetBrokerage", |
238 | 240 | "GetChainParameters", |
239 | 241 | "GetContract", |
| 242 | + "GetContractInfo", |
240 | 243 | "GetDelegatedResource", |
241 | 244 | "GetDelegatedResourceAccountIndex", |
242 | 245 | "GetDiversifier", |
@@ -2108,11 +2111,11 @@ private void deployContract(String[] parameter) |
2108 | 2111 | System.out.println("origin_energy_limit must > 0"); |
2109 | 2112 | return; |
2110 | 2113 | } |
2111 | | - if (!constructorStr.equals("#")) { |
| 2114 | + if (!(constructorStr.equals("#") || argsStr.equals("#"))) { |
2112 | 2115 | if (isHex) { |
2113 | 2116 | codeStr += argsStr; |
2114 | 2117 | } else { |
2115 | | - codeStr += AbiUtil.parseMethod(constructorStr, argsStr); |
| 2118 | + codeStr += Hex.toHexString(AbiUtil.encodeInput(constructorStr, argsStr)); |
2116 | 2119 | } |
2117 | 2120 | } |
2118 | 2121 | long value = 0; |
@@ -2240,6 +2243,28 @@ private void getContract(String[] parameters) { |
2240 | 2243 | } |
2241 | 2244 | } |
2242 | 2245 |
|
| 2246 | + private void getContractInfo(String[] parameters) { |
| 2247 | + if (parameters == null || |
| 2248 | + parameters.length != 1) { |
| 2249 | + System.out.println("Using getContractInfo needs 1 parameter like: "); |
| 2250 | + System.out.println("GetContractInfo contractAddress"); |
| 2251 | + return; |
| 2252 | + } |
| 2253 | + |
| 2254 | + byte[] addressBytes = WalletApi.decodeFromBase58Check(parameters[0]); |
| 2255 | + if (addressBytes == null) { |
| 2256 | + System.out.println("GetContractInfo: invalid address !!!"); |
| 2257 | + return; |
| 2258 | + } |
| 2259 | + |
| 2260 | + SmartContractDataWrapper contractDeployContract = WalletApi.getContractInfo(addressBytes); |
| 2261 | + if (contractDeployContract != null) { |
| 2262 | + System.out.println(Utils.formatMessageString(contractDeployContract)); |
| 2263 | + } else { |
| 2264 | + System.out.println("Query contract failed !!!"); |
| 2265 | + } |
| 2266 | + } |
| 2267 | + |
2243 | 2268 | private void generateAddress() { |
2244 | 2269 | AddressPrKeyPairMessage result = walletApiWrapper.generateAddress(); |
2245 | 2270 | if (null != result) { |
@@ -3682,7 +3707,7 @@ public static String[] getCmd(String cmdLine) { |
3682 | 3707 | || cmdLine.toLowerCase().startsWith("triggercontract") |
3683 | 3708 | || cmdLine.toLowerCase().startsWith("triggerconstantcontract") |
3684 | 3709 | || cmdLine.toLowerCase().startsWith("updateaccountpermission")) { |
3685 | | - return cmdLine.split(" ", -1); |
| 3710 | + return cmdLine.split("\\s+", -1); |
3686 | 3711 | } |
3687 | 3712 | String[] strArray = cmdLine.split("\""); |
3688 | 3713 | int num = strArray.length; |
@@ -4081,6 +4106,10 @@ private void run() { |
4081 | 4106 | getContract(parameters); |
4082 | 4107 | break; |
4083 | 4108 | } |
| 4109 | + case "getcontractinfo": { |
| 4110 | + getContractInfo(parameters); |
| 4111 | + break; |
| 4112 | + } |
4084 | 4113 | case "generateaddress": { |
4085 | 4114 | generateAddress(); |
4086 | 4115 | break; |
|
0 commit comments