Skip to content

Commit f9e773d

Browse files
authored
Merge pull request #401 from tronprotocol/develop
merge develop
2 parents 40a16e9 + a469299 commit f9e773d

File tree

7 files changed

+63
-5
lines changed

7 files changed

+63
-5
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ fullnode = {
2525
}
2626
2727
soliditynode = {
28+
// the IPs in this list can only be totally set to solidity or pBFT.
2829
ip.list = [
29-
"solidity ip : port"
30+
"ip : solidity port" // default solidity
3031
]
32+
# ip.list = [
33+
# "ip : pBFT port" // or pBFT
34+
# ]
3135
} // NOTE: solidity node is optional
3236
3337
blockNumberStartToScan = 22690588 // NOTE: this field is optional

src/main/java/org/tron/walletcli/Client.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.tron.protos.contract.SmartContractOuterClass.SmartContract;
5757
import org.tron.protos.Protocol.Transaction;
5858
import org.tron.protos.Protocol.TransactionInfo;
59+
import org.tron.protos.contract.SmartContractOuterClass.SmartContractDataWrapper;
5960
import org.tron.walletserver.WalletApi;
6061

6162

@@ -108,6 +109,7 @@ public class Client {
108109
"GetBrokerage",
109110
"GetChainParameters",
110111
"GetContract contractAddress",
112+
"GetContractInfo contractAddress",
111113
"GetDelegatedResource",
112114
"GetDelegatedResourceAccountIndex",
113115
"GetDiversifier",
@@ -237,6 +239,7 @@ public class Client {
237239
"GetBrokerage",
238240
"GetChainParameters",
239241
"GetContract",
242+
"GetContractInfo",
240243
"GetDelegatedResource",
241244
"GetDelegatedResourceAccountIndex",
242245
"GetDiversifier",
@@ -2108,11 +2111,11 @@ private void deployContract(String[] parameter)
21082111
System.out.println("origin_energy_limit must > 0");
21092112
return;
21102113
}
2111-
if (!constructorStr.equals("#")) {
2114+
if (!(constructorStr.equals("#") || argsStr.equals("#"))) {
21122115
if (isHex) {
21132116
codeStr += argsStr;
21142117
} else {
2115-
codeStr += AbiUtil.parseMethod(constructorStr, argsStr);
2118+
codeStr += Hex.toHexString(AbiUtil.encodeInput(constructorStr, argsStr));
21162119
}
21172120
}
21182121
long value = 0;
@@ -2240,6 +2243,28 @@ private void getContract(String[] parameters) {
22402243
}
22412244
}
22422245

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+
22432268
private void generateAddress() {
22442269
AddressPrKeyPairMessage result = walletApiWrapper.generateAddress();
22452270
if (null != result) {
@@ -3682,7 +3707,7 @@ public static String[] getCmd(String cmdLine) {
36823707
|| cmdLine.toLowerCase().startsWith("triggercontract")
36833708
|| cmdLine.toLowerCase().startsWith("triggerconstantcontract")
36843709
|| cmdLine.toLowerCase().startsWith("updateaccountpermission")) {
3685-
return cmdLine.split(" ", -1);
3710+
return cmdLine.split("\\s+", -1);
36863711
}
36873712
String[] strArray = cmdLine.split("\"");
36883713
int num = strArray.length;
@@ -4081,6 +4106,10 @@ private void run() {
40814106
getContract(parameters);
40824107
break;
40834108
}
4109+
case "getcontractinfo": {
4110+
getContractInfo(parameters);
4111+
break;
4112+
}
40844113
case "generateaddress": {
40854114
generateAddress();
40864115
break;

src/main/java/org/tron/walletserver/GrpcClient.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import org.tron.protos.Protocol.Transaction;
6363
import org.tron.protos.Protocol.TransactionInfo;
6464
import org.tron.protos.Protocol.TransactionSign;
65+
import org.tron.protos.contract.SmartContractOuterClass.SmartContractDataWrapper;
6566
import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract;
6667
import org.tron.protos.contract.SmartContractOuterClass.UpdateEnergyLimitContract;
6768
import org.tron.protos.contract.SmartContractOuterClass.UpdateSettingContract;
@@ -838,6 +839,12 @@ public SmartContract getContract(byte[] address) {
838839
return blockingStubFull.getContract(bytesMessage);
839840
}
840841

842+
public SmartContractDataWrapper getContractInfo(byte[] address) {
843+
ByteString byteString = ByteString.copyFrom(address);
844+
BytesMessage bytesMessage = BytesMessage.newBuilder().setValue(byteString).build();
845+
return blockingStubFull.getContractInfo(bytesMessage);
846+
}
847+
841848
public TransactionExtention accountPermissionUpdate(
842849
AccountPermissionUpdateContract request) {
843850
return blockingStubFull.accountPermissionUpdate(request);

src/main/java/org/tron/walletserver/WalletApi.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
import org.tron.protos.contract.ShieldContract.OutputPointInfo;
109109
import org.tron.protos.contract.ShieldContract.ShieldedTransferContract;
110110
import org.tron.protos.contract.ShieldContract.SpendDescription;
111+
import org.tron.protos.contract.SmartContractOuterClass.SmartContractDataWrapper;
111112
import org.tron.protos.contract.SmartContractOuterClass.TriggerSmartContract;
112113
import org.tron.protos.contract.StorageContract.BuyStorageBytesContract;
113114
import org.tron.protos.contract.StorageContract.BuyStorageContract;
@@ -139,6 +140,7 @@
139140
import org.tron.protos.contract.WitnessContract.WitnessUpdateContract;
140141
import org.tron.protos.contract.MarketContract.MarketCancelOrderContract;
141142
import org.tron.protos.contract.MarketContract.MarketSellAssetContract;
143+
import org.tron.protos.contract.MarketContract.MarketSellAssetContract;
142144

143145
import java.io.File;
144146
import java.io.IOException;
@@ -2211,6 +2213,10 @@ public static SmartContract getContract(byte[] address) {
22112213
return rpcCli.getContract(address);
22122214
}
22132215

2216+
public static SmartContractDataWrapper getContractInfo(byte[] address) {
2217+
return rpcCli.getContractInfo(address);
2218+
}
2219+
22142220
public boolean accountPermissionUpdate(byte[] owner, String permissionJson)
22152221
throws CipherException, IOException, CancelException {
22162222
AccountPermissionUpdateContract contract =

src/main/protos/api/api.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ service Wallet {
433433
rpc GetContract (BytesMessage) returns (SmartContract) {
434434
}
435435

436+
rpc GetContractInfo (BytesMessage) returns (SmartContractDataWrapper) {
437+
}
438+
436439
rpc TriggerContract (TriggerSmartContract) returns (TransactionExtention) {
437440
}
438441

src/main/protos/core/contract/smart_contract.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ message UpdateEnergyLimitContract {
8888
bytes contract_address = 2;
8989
int64 origin_energy_limit = 3;
9090
}
91+
92+
message SmartContractDataWrapper {
93+
SmartContract smart_contract = 1;
94+
bytes runtimecode = 2;
95+
}

src/main/resources/config.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ fullnode = {
99
}
1010

1111
#soliditynode = {
12+
# // the IPs in this list can only be totally set to solidity or pBFT.
1213
# ip.list = [
13-
# "127.0.0.1:50052"
14+
# "127.0.0.1:50052" // default solidity
15+
# ]
16+
# ip.list = [
17+
# "127.0.0.1:50071" // or pBFT
1418
# ]
1519
#}
1620

0 commit comments

Comments
 (0)