diff options
author | Maran <maran.hidskes@gmail.com> | 2014-06-04 21:54:33 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-06-04 21:54:33 +0800 |
commit | 7843390ecd52df37a28282d76be198d5456ce385 (patch) | |
tree | 42ab782f2bbd2246481d7336c424e835004064ff | |
parent | 307fe4a3cd4ff2d3910ed992e6e98a7cd3ca6f87 (diff) | |
download | go-tangerine-7843390ecd52df37a28282d76be198d5456ce385.tar go-tangerine-7843390ecd52df37a28282d76be198d5456ce385.tar.gz go-tangerine-7843390ecd52df37a28282d76be198d5456ce385.tar.bz2 go-tangerine-7843390ecd52df37a28282d76be198d5456ce385.tar.lz go-tangerine-7843390ecd52df37a28282d76be198d5456ce385.tar.xz go-tangerine-7843390ecd52df37a28282d76be198d5456ce385.tar.zst go-tangerine-7843390ecd52df37a28282d76be198d5456ce385.zip |
Implement getStateKeyVal for JS bindings.
Gives JS the option to 'loop' over contract key/val storage
-rw-r--r-- | ethereal/assets/ext/ethereum.js | 4 | ||||
-rw-r--r-- | ethereal/assets/qml/webapp.qml | 9 | ||||
-rw-r--r-- | ethereal/ui/gui.go | 2 | ||||
-rw-r--r-- | ethereum/repl.go | 6 |
4 files changed, 18 insertions, 3 deletions
diff --git a/ethereal/assets/ext/ethereum.js b/ethereal/assets/ext/ethereum.js index d4eaf97fd..c58fe24c2 100644 --- a/ethereal/assets/ext/ethereum.js +++ b/ethereal/assets/ext/ethereum.js @@ -32,6 +32,10 @@ window.eth = { postData({call: "getStorage", args: [address, storageAddress]}, cb); }, + getStateKeyVals: function(address, cb){ + postData({call: "getStateKeyVals", args: [address]}, cb); + }, + getKey: function(cb) { postData({call: "getKey"}, cb); }, diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml index d3cffeeca..ec236a18c 100644 --- a/ethereal/assets/qml/webapp.qml +++ b/ethereal/assets/qml/webapp.qml @@ -34,7 +34,6 @@ ApplicationWindow { top: parent.top } */ - onTitleChanged: { window.title = title } experimental.preferences.javascriptEnabled: true experimental.preferences.navigatorQtObjectEnabled: true @@ -98,6 +97,12 @@ ApplicationWindow { postData(data._seed, storage) break + case "getStateKeyVals": + require(1); + var stateObject = eth.getStateObject(data.args[0]).stateKeyVal(true) + postData(data._seed,stateObject) + + break case "getBalance": require(1); @@ -188,7 +193,7 @@ ApplicationWindow { WebView { id: inspector - visible: false + visible: true url: webview.experimental.remoteInspectorUrl anchors { left: root.left diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index 9fc1abc28..4dda5017f 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -65,6 +65,8 @@ func (gui *Gui) Start(assetPath string) { Init: func(p *ethpub.PBlock, obj qml.Object) { p.Number = 0; p.Hash = "" }, }, { Init: func(p *ethpub.PTx, obj qml.Object) { p.Value = ""; p.Hash = ""; p.Address = "" }, + }, { + Init: func(p *ethpub.KeyVal, obj qml.Object) { p.Key = ""; p.Value = "" }, }}) ethutil.Config.SetClientString(fmt.Sprintf("/Ethereal v%s", version)) diff --git a/ethereum/repl.go b/ethereum/repl.go index e59814154..0208459ad 100644 --- a/ethereum/repl.go +++ b/ethereum/repl.go @@ -78,6 +78,10 @@ func (self *JSEthereum) GetStateObject(addr string) otto.Value { return self.toVal(self.PEthereum.GetStateObject(addr)) } +func (self *JSEthereum) GetStateKeyVals(addr string) otto.Value { + return self.toVal(self.PEthereum.GetStateObject(addr).StateKeyVal(false)) +} + func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value { r, err := self.PEthereum.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr) if err != nil { @@ -105,7 +109,7 @@ func (self *JSEthereum) toVal(v interface{}) otto.Value { result, err := self.vm.ToValue(v) if err != nil { - fmt.Println(err) + fmt.Println("Value unknown:", err) return otto.UndefinedValue() } |