Integrating ContractCreationDialog (now sending tx yet)
This commit is contained in:
parent
e5f4515cb1
commit
c141dd98a6
|
@ -68,11 +68,11 @@ public class SystemProperties {
|
|||
return Integer.parseInt(prop.getProperty("transaction.approve.timeout"));
|
||||
}
|
||||
|
||||
|
||||
public String clientName() {
|
||||
|
||||
public String peerDiscoveryIP(){
|
||||
if(prop.isEmpty()) return "";
|
||||
return prop.getProperty("client.name");
|
||||
}
|
||||
return prop.getProperty("peer.discovery.ip");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Enumeration<?> e = prop.propertyNames();
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.ethereum.gui;
|
|||
import org.ethereum.core.Transaction;
|
||||
import org.ethereum.manager.MainData;
|
||||
import org.ethereum.net.client.ClientPeer;
|
||||
import org.ethereum.util.Utils;
|
||||
import org.ethereum.wallet.AddressState;
|
||||
import org.spongycastle.util.BigIntegers;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
@ -22,6 +23,7 @@ import java.awt.event.MouseAdapter;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* www.ethereumJ.com
|
||||
|
@ -36,7 +38,7 @@ class ContractSubmitDialog extends JDialog {
|
|||
AddressState addressState = null;
|
||||
JLabel statusMsg = null;
|
||||
|
||||
public ContractSubmitDialog(Frame parent, final AddressState addressState) {
|
||||
public ContractSubmitDialog(Frame parent, String byteCode) {
|
||||
super(parent, "Contract Details: ", false);
|
||||
dialog = this;
|
||||
|
||||
|
@ -56,6 +58,7 @@ class ContractSubmitDialog extends JDialog {
|
|||
JScrollPane contractDataInput = new JScrollPane(contractDataTA);
|
||||
GUIUtils.addStyle(contractDataTA, null, false);
|
||||
GUIUtils.addStyle(contractDataInput, "Data:");
|
||||
contractDataTA.setText(byteCode);
|
||||
|
||||
this.getContentPane().setBackground(Color.WHITE);
|
||||
this.getContentPane().setLayout(null);
|
||||
|
@ -137,7 +140,21 @@ class ContractSubmitDialog extends JDialog {
|
|||
JComponent editor = (JComponent)(jComboBox.getEditor().getEditorComponent());
|
||||
editor.setForeground(Color.RED);
|
||||
|
||||
jComboBox.addItem(" By: 1f21c - 1000 (10^9)");
|
||||
Collection<AddressState> addressStates =
|
||||
MainData.instance.getWallet().getAddressStateCollection();
|
||||
|
||||
for (AddressState addressState : addressStates){
|
||||
|
||||
String addressShort = Utils.getAddressShortString(addressState.getEcKey().getAddress());
|
||||
String valueShort = Utils.getValueShortString(addressState.getBalance());
|
||||
|
||||
String addresText =
|
||||
String.format(" By: [%s] %s",
|
||||
addressShort, valueShort);
|
||||
|
||||
jComboBox.addItem(addresText);
|
||||
}
|
||||
|
||||
jComboBox.setRenderer(new DefaultListCellRenderer() {
|
||||
|
||||
@Override
|
||||
|
@ -187,7 +204,7 @@ class ContractSubmitDialog extends JDialog {
|
|||
if (parent != null) {
|
||||
Dimension parentSize = parent.getSize();
|
||||
Point p = parent.getLocation();
|
||||
setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
|
||||
setLocation(p.x + parentSize.width / 4, p.y + 10);
|
||||
}
|
||||
|
||||
JRootPane rootPane = new JRootPane();
|
||||
|
@ -223,7 +240,7 @@ class ContractSubmitDialog extends JDialog {
|
|||
|
||||
AddressState as = new AddressState();
|
||||
|
||||
ContractSubmitDialog pod = new ContractSubmitDialog(null, as);
|
||||
ContractSubmitDialog pod = new ContractSubmitDialog(null, "");
|
||||
|
||||
|
||||
pod.setVisible(true);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.ethereum.gui;
|
||||
|
||||
import org.abego.treelayout.internal.util.Contract;
|
||||
import org.ethereum.serpent.SerpentCompiler;
|
||||
import org.fife.ui.rsyntaxtextarea.AbstractTokenMakerFactory;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
|
@ -57,7 +58,7 @@ public class SerpentEditor extends JFrame {
|
|||
Toolkit kit = Toolkit.getDefaultToolkit();
|
||||
Image img = kit.createImage(url);
|
||||
this.setIconImage(img);
|
||||
this.setLocation(30, 80);
|
||||
this.setLocation(30, 70);
|
||||
|
||||
AbstractTokenMakerFactory atmf = (AbstractTokenMakerFactory)TokenMakerFactory.getDefaultInstance();
|
||||
atmf.putMapping("text/serpent", "org.ethereum.gui.SerpentTokenMaker");
|
||||
|
@ -89,11 +90,43 @@ public class SerpentEditor extends JFrame {
|
|||
splitPanel.add(result);
|
||||
|
||||
JPanel controlsPanel = new JPanel();
|
||||
FlowLayout fl = new FlowLayout(FlowLayout.LEADING, 30, 5);
|
||||
FlowLayout fl = new FlowLayout(FlowLayout.LEADING, 10, 5);
|
||||
fl.setAlignment(FlowLayout.RIGHT);
|
||||
controlsPanel.setLayout(fl);
|
||||
|
||||
JButton buildButton = new JButton("Build");
|
||||
JButton sendButton = new JButton("Send");
|
||||
|
||||
sendButton.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
|
||||
String asmResult = "";
|
||||
try {
|
||||
|
||||
// todo: integrate new compiler when avail
|
||||
asmResult = SerpentCompiler.compile(codeArea.getText());
|
||||
} catch (Throwable th) {
|
||||
th.printStackTrace();
|
||||
|
||||
splitPanel.setDividerLocation(0.7);
|
||||
result.setVisible(true);
|
||||
result.setText(th.getMessage());
|
||||
result.setForeground(Color.RED);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
String machineCode = SerpentCompiler.compileAssemblyToMachine(asmResult);
|
||||
|
||||
ContractSubmitDialog payOutDialog =
|
||||
new ContractSubmitDialog((Frame)SwingUtilities.getAncestorOfClass(JFrame.class,
|
||||
cp), machineCode);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
buildButton.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -122,6 +155,7 @@ public class SerpentEditor extends JFrame {
|
|||
});
|
||||
|
||||
|
||||
controlsPanel.add(sendButton);
|
||||
controlsPanel.add(buildButton);
|
||||
|
||||
cp.add(controlsPanel, BorderLayout.SOUTH);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class WalletAddressPanel extends JPanel{
|
|||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
PayOutDialog payOutDialog =
|
||||
new PayOutDialog((Frame)SwingUtilities.getAncestorOfClass(Frame.class,
|
||||
new PayOutDialog((Frame)SwingUtilities.getAncestorOfClass(JFrame.class,
|
||||
walletAddressPanel), addressState);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package org.ethereum.manager;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
|
||||
import com.maxmind.geoip.Location;
|
||||
import org.ethereum.config.SystemProperties;
|
||||
import org.ethereum.core.Block;
|
||||
import org.ethereum.core.Genesis;
|
||||
import org.ethereum.core.Transaction;
|
||||
|
@ -21,6 +25,8 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import static org.ethereum.config.SystemProperties.CONFIG;
|
||||
|
||||
/**
|
||||
* www.ethereumJ.com
|
||||
* User: Roman Mandeleil
|
||||
|
@ -44,8 +50,16 @@ public class MainData {
|
|||
|
||||
public MainData() {
|
||||
|
||||
InetAddress ip = null;
|
||||
try {
|
||||
ip = InetAddress.getByName(CONFIG.peerDiscoveryIP());
|
||||
} catch (UnknownHostException e) {
|
||||
System.exit(-1);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
PeerData peer = new PeerData(
|
||||
new byte[]{54 , (byte)201, 28, 117}, (short) 30303, new byte[]{00});
|
||||
ip.getAddress(), (short) 30303, new byte[]{00});
|
||||
peers.add(peer);
|
||||
|
||||
byte[] cowAddr = HashUtil.sha3("cow".getBytes());
|
||||
|
|
|
@ -26,7 +26,7 @@ public class StaticMessages {
|
|||
byte[] peerIdBytes = HashUtil.randomPeerId();
|
||||
|
||||
HELLO_MESSAGE = new HelloMessage((byte) 0x11, (byte) 0x00,
|
||||
CONFIG.clientName(), (byte) 0b00000111,
|
||||
"EthereumJ [v0.5.1] by RomanJ", (byte) 0b00000111,
|
||||
(short) 30303, peerIdBytes);
|
||||
}
|
||||
public static final HelloMessage HELLO_MESSAGE;
|
||||
|
|
|
@ -41,7 +41,24 @@ public class Utils {
|
|||
result = result.divide(_1000_);
|
||||
pow += 3;
|
||||
}
|
||||
return result.toString() + " (" + "10^" + pow + ")";
|
||||
return result.toString() + "·(" + "10^" + pow + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param addr length should be 20
|
||||
* @return short string represent 1f21c...
|
||||
*/
|
||||
public static String getAddressShortString(byte[] addr){
|
||||
|
||||
if (addr == null || addr.length != 20) throw new Error("not an address");
|
||||
|
||||
String addrShort = Hex.toHexString(addr, 0, 3);
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(addrShort);
|
||||
sb.append("...");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static SecureRandom getRandom(){
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
server.acceptConnections = false
|
||||
|
||||
|
||||
# one default access point to start
|
||||
# discover the network e.g. [54.201.28.117]
|
||||
peer.discovery.ip = 54.201.28.117
|
||||
|
||||
# specify if the mechanism
|
||||
# to discover more and more
|
||||
# peers and check the already
|
||||
|
@ -22,7 +26,7 @@ peer.discovery.workers = 5
|
|||
|
||||
# connection timeout for trying to
|
||||
# connect to a peer [seconds]
|
||||
peer.discovery.timeout = 3
|
||||
peer.discovery.timeout = 2
|
||||
|
||||
# the time we wait to the network
|
||||
# to approve the transaction, the
|
||||
|
|
Loading…
Reference in New Issue