|
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", |
@@ -2237,6 +2240,28 @@ private void getContract(String[] parameters) { |
2237 | 2240 | } |
2238 | 2241 | } |
2239 | 2242 |
|
| 2243 | + private void getContractInfo(String[] parameters) { |
| 2244 | + if (parameters == null || |
| 2245 | + parameters.length != 1) { |
| 2246 | + System.out.println("Using getContractInfo needs 1 parameter like: "); |
| 2247 | + System.out.println("GetContractInfo contractAddress"); |
| 2248 | + return; |
| 2249 | + } |
| 2250 | + |
| 2251 | + byte[] addressBytes = WalletApi.decodeFromBase58Check(parameters[0]); |
| 2252 | + if (addressBytes == null) { |
| 2253 | + System.out.println("GetContractInfo: invalid address !!!"); |
| 2254 | + return; |
| 2255 | + } |
| 2256 | + |
| 2257 | + SmartContractDataWrapper contractDeployContract = WalletApi.getContractInfo(addressBytes); |
| 2258 | + if (contractDeployContract != null) { |
| 2259 | + System.out.println(Utils.formatMessageString(contractDeployContract)); |
| 2260 | + } else { |
| 2261 | + System.out.println("Query contract failed !!!"); |
| 2262 | + } |
| 2263 | + } |
| 2264 | + |
2240 | 2265 | private void generateAddress() { |
2241 | 2266 | AddressPrKeyPairMessage result = walletApiWrapper.generateAddress(); |
2242 | 2267 | if (null != result) { |
@@ -4078,6 +4103,10 @@ private void run() { |
4078 | 4103 | getContract(parameters); |
4079 | 4104 | break; |
4080 | 4105 | } |
| 4106 | + case "getcontractinfo": { |
| 4107 | + getContractInfo(parameters); |
| 4108 | + break; |
| 4109 | + } |
4081 | 4110 | case "generateaddress": { |
4082 | 4111 | generateAddress(); |
4083 | 4112 | break; |
|
0 commit comments