Fix ContractCallDialog error
This commit is contained in:
parent
e62c9d8e2a
commit
028cfe5ca3
|
@ -62,6 +62,10 @@ public class Utils {
|
|||
}
|
||||
return result.toString() + "·(" + "10^" + pow + ")";
|
||||
}
|
||||
|
||||
public static boolean isValidAddress(byte[] addr) {
|
||||
return addr != null && addr.length == 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param addr length should be 20
|
||||
|
@ -69,7 +73,7 @@ public class Utils {
|
|||
*/
|
||||
public static String getAddressShortString(byte[] addr) {
|
||||
|
||||
if (addr == null || addr.length != 20) throw new Error("not an address");
|
||||
if (!isValidAddress(addr)) throw new Error("not an address");
|
||||
|
||||
String addrShort = Hex.toHexString(addr, 0, 3);
|
||||
|
||||
|
|
|
@ -305,6 +305,11 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog {
|
|||
private void playContractCall() {
|
||||
|
||||
byte[] contractAddress = Hex.decode(contractAddrInput.getText());
|
||||
if (!Utils.isValidAddress(contractAddress)) {
|
||||
alertStatusMsg("Not a valid contract address");
|
||||
return;
|
||||
}
|
||||
|
||||
ContractDetails contractDetails = UIEthereumManager.ethereum.getRepository().getContractDetails(contractAddress);
|
||||
if (contractDetails == null) {
|
||||
alertStatusMsg("No contract for that address");
|
||||
|
|
Loading…
Reference in New Issue