aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-04-24 06:01:22 +0800
committerobscuren <geffobscura@gmail.com>2014-04-24 06:01:22 +0800
commitbb72347acf8a82d1c20e8aae25c84e5dc75903dd (patch)
treec2ab64cf4bbbe23a9efab8efa1087ba775e12aa2 /ethereal
parent43f1214f97e52863b1f1ef7913991bef3d00c58e (diff)
downloaddexon-bb72347acf8a82d1c20e8aae25c84e5dc75903dd.tar
dexon-bb72347acf8a82d1c20e8aae25c84e5dc75903dd.tar.gz
dexon-bb72347acf8a82d1c20e8aae25c84e5dc75903dd.tar.bz2
dexon-bb72347acf8a82d1c20e8aae25c84e5dc75903dd.tar.lz
dexon-bb72347acf8a82d1c20e8aae25c84e5dc75903dd.tar.xz
dexon-bb72347acf8a82d1c20e8aae25c84e5dc75903dd.tar.zst
dexon-bb72347acf8a82d1c20e8aae25c84e5dc75903dd.zip
Minor fixes and sample coin "improvements"
Diffstat (limited to 'ethereal')
-rw-r--r--ethereal/assets/ethereum.js12
-rw-r--r--ethereal/assets/icon.pngbin0 -> 86700 bytes
-rw-r--r--ethereal/assets/qml/webapp.qml23
-rw-r--r--ethereal/assets/test.html54
-rw-r--r--ethereal/ethereum.go2
-rw-r--r--ethereal/ui/gui.go14
-rw-r--r--ethereal/ui/library.go24
-rw-r--r--ethereal/ui/ui_lib.go2
8 files changed, 108 insertions, 23 deletions
diff --git a/ethereal/assets/ethereum.js b/ethereal/assets/ethereum.js
index 173eaff22..74f851936 100644
--- a/ethereal/assets/ethereum.js
+++ b/ethereal/assets/ethereum.js
@@ -5,6 +5,10 @@ function postData(data, cb) {
eth._callbacks[data._seed] = cb;
}
+ if(data.args === undefined) {
+ data.args = []
+ }
+
navigator.qt.postMessage(JSON.stringify(data));
}
@@ -34,6 +38,14 @@ window.eth = {
createTx: function(recipient, value, gas, gasPrice, data, cb) {
postData({call: "createTx", args: [recipient, value, gas, gasPrice, data]}, cb)
},
+
+ getStorage: function(address, storageAddress, cb) {
+ postData({call: "getStorage", args: [address, storageAddress]}, cb)
+ },
+
+ getKey: function(cb) {
+ postData({call: "getKey"}, cb)
+ },
}
window.eth._callbacks = {}
diff --git a/ethereal/assets/icon.png b/ethereal/assets/icon.png
new file mode 100644
index 000000000..73e0ceb75
--- /dev/null
+++ b/ethereal/assets/icon.png
Binary files differ
diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml
index 496beb65a..ee7dea0ca 100644
--- a/ethereal/assets/qml/webapp.qml
+++ b/ethereal/assets/qml/webapp.qml
@@ -25,12 +25,15 @@ ApplicationWindow {
WebView {
objectName: "webView"
id: webview
+ anchors.fill: parent
+ /*
anchors {
left: parent.left
right: parent.right
bottom: sizeGrip.top
top: parent.top
}
+ */
onTitleChanged: { window.title = title }
experimental.preferences.javascriptEnabled: true
@@ -38,7 +41,7 @@ ApplicationWindow {
experimental.preferences.developerExtrasEnabled: true
experimental.userScripts: [ui.assetPath("ethereum.js")]
experimental.onMessageReceived: {
- console.log("[onMessageReceived]: ", message.data)
+ //console.log("[onMessageReceived]: ", message.data)
var data = JSON.parse(message.data)
switch(data.call) {
@@ -57,6 +60,20 @@ ApplicationWindow {
var tx = eth.createTx(data.args[0], data.args[1],data.args[2],data.args[3],data.args[4])
postData(data._seed, tx)
}
+ break
+ case "getStorage":
+ if(data.args.length < 2) {
+ postData(data._seed, null)
+ } else {
+ var stateObject = eth.getStateObject(data.args[0])
+ var storage = stateObject.getStorage(data.args[1])
+ postData(data._seed, storage)
+ }
+ break
+ case "getKey":
+ var keys = eth.getKey()
+ postData(data._seed, keys)
+ break
}
}
function postData(seed, data) {
@@ -67,7 +84,7 @@ ApplicationWindow {
Rectangle {
id: sizeGrip
color: "gray"
- visible: true
+ visible: false
height: 10
anchors {
left: root.left
@@ -86,7 +103,7 @@ ApplicationWindow {
WebView {
id: inspector
- visible: true
+ visible: false
url: webview.experimental.remoteInspectorUrl
anchors {
left: root.left
diff --git a/ethereal/assets/test.html b/ethereal/assets/test.html
index eb55bf667..1cfcad6bb 100644
--- a/ethereal/assets/test.html
+++ b/ethereal/assets/test.html
@@ -1,37 +1,57 @@
<html>
<head>
<title>jeffcoin</title>
-<body>
-<h1>Jeff Coin</h1>
-
-<img src="file:///Users/jeffrey/Desktop/iconnew.png">
-
-<div id="transactions">
- <input id="addr" type="text" placeholder="Receiver address"></input><br>
- <input id="amount" type="text" placeholder="Amount"></input><br>
- <button onclick="createTransaction();">Send Tx</button>
-</div>
-
-<div><button onclick="test();">Tests</button></div>
-
<script type="text/javascript">
+var jefcoinAddr = "3dff537f51350239abc95c76a5864aa605259e7d"
+
function createTransaction() {
- debug("test")
var addr = document.querySelector("#addr").value;
var amount = document.querySelector("#amount").value;
- eth.createTx(addr, amount, "100", "250", "", function(tx) {
+ var data = "0x" + addr + "\n" + amount
+ eth.createTx(jefcoinAddr, 0, "10000000", "250", data, function(tx) {
debug("received tx hash:", tx)
})
}
// Any test related actions here please
function tests() {
- eth.getBlock(1, function(block) {
- debug("queried block:", block)
+ eth.getKey(function(keys) {
+ debug(keys)
+ })
+}
+
+function init() {
+ eth.getKey(function(key) {
+ eth.getStorage(jefcoinAddr, key, function(storage) {
+ debug("Currently in storage: ", storage);
+ document.querySelector("#currentAmount").innerHTML = "Amount: " + storage;
+ })
})
}
+
</script>
+<style type="text/css">
+input[type="text"] {
+ width: 300px;
+}
+</style>
+</head>
+
+<body onload="init();">
+<h1>Jeff Coin</h1>
+
+<img src="icon.png">
+<div id="currentAmount"></div>
+
+<div id="transactions">
+ <input id="addr" type="text" placeholder="Receiver address"></input><br>
+ <input id="amount" type="text" placeholder="Amount"></input><br>
+ <button onclick="createTransaction();">Send Tx</button>
+</div>
+
+<div><button onclick="tests();">Tests</button></div>
+
<div id="debug" style="border: 1px solid block"></div>
diff --git a/ethereal/ethereum.go b/ethereal/ethereum.go
index 9cc52039d..0adb9f151 100644
--- a/ethereal/ethereum.go
+++ b/ethereal/ethereum.go
@@ -7,7 +7,7 @@ import (
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/ethereal/ui"
"github.com/ethereum/go-ethereum/utils"
- "github.com/niemeyer/qml"
+ "github.com/go-qml/qml"
"log"
"os"
"os/signal"
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 0e5d57c93..80498d718 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -8,7 +8,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethutil"
- "github.com/niemeyer/qml"
+ "github.com/go-qml/qml"
"math/big"
"strings"
)
@@ -24,6 +24,18 @@ type Tx struct {
Contract bool
}
+type Key struct {
+ Address string
+}
+
+type KeyRing struct {
+ Keys []interface{}
+}
+
+func NewKeyRing(keys []interface{}) *KeyRing {
+ return &KeyRing{Keys: keys}
+}
+
func NewTxFromTransaction(tx *ethchain.Transaction) *Tx {
hash := hex.EncodeToString(tx.Hash())
sender := hex.EncodeToString(tx.Recipient)
diff --git a/ethereal/ui/library.go b/ethereal/ui/library.go
index 537cfa994..5ca2b4273 100644
--- a/ethereal/ui/library.go
+++ b/ethereal/ui/library.go
@@ -10,6 +10,20 @@ import (
"strings"
)
+type Contract struct {
+ object *ethchain.StateObject
+}
+
+func NewContract(object *ethchain.StateObject) *Contract {
+ return &Contract{object: object}
+}
+
+func (c *Contract) GetStorage(address string) string {
+ val := c.object.GetMem(ethutil.Big("0x" + address))
+
+ return val.BigInt().String()
+}
+
type EthLib struct {
stateManager *ethchain.StateManager
blockChain *ethchain.BlockChain
@@ -43,6 +57,16 @@ func (lib *EthLib) CreateAndSetPrivKey() (string, string, string, string) {
return mnemonicString, fmt.Sprintf("%x", pair.Address()), fmt.Sprintf("%x", prv), fmt.Sprintf("%x", pub)
}
+func (lib *EthLib) GetKey() string {
+ return ethutil.Hex(ethutil.Config.Db.GetKeys()[0].Address())
+}
+
+func (lib *EthLib) GetStateObject(address string) *Contract {
+ stateObject := lib.stateManager.ProcState().GetContract(ethutil.FromHex(address))
+
+ return NewContract(stateObject)
+}
+
func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
var hash []byte
var contractCreation bool
diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go
index 09f81c67e..9191e5ea9 100644
--- a/ethereal/ui/ui_lib.go
+++ b/ethereal/ui/ui_lib.go
@@ -7,7 +7,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
- "github.com/niemeyer/qml"
+ "github.com/go-qml/qml"
"os"
"path"
"path/filepath"