aboutsummaryrefslogtreecommitdiffstats
path: root/mist/ui_lib.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-09-22 20:54:27 +0800
committerobscuren <geffobscura@gmail.com>2014-09-22 20:54:27 +0800
commitb4bd70c402e75f933e694e9f9df14912df468e69 (patch)
tree99bb9d0219a9ed9f4a617e01db4eb5c84a0a34b3 /mist/ui_lib.go
parent8585e59718e6b75a38833801f1725730c1b9fb01 (diff)
downloaddexon-b4bd70c402e75f933e694e9f9df14912df468e69.tar
dexon-b4bd70c402e75f933e694e9f9df14912df468e69.tar.gz
dexon-b4bd70c402e75f933e694e9f9df14912df468e69.tar.bz2
dexon-b4bd70c402e75f933e694e9f9df14912df468e69.tar.lz
dexon-b4bd70c402e75f933e694e9f9df14912df468e69.tar.xz
dexon-b4bd70c402e75f933e694e9f9df14912df468e69.tar.zst
dexon-b4bd70c402e75f933e694e9f9df14912df468e69.zip
Re-wrote ethereum.js
Diffstat (limited to 'mist/ui_lib.go')
-rw-r--r--mist/ui_lib.go44
1 files changed, 36 insertions, 8 deletions
diff --git a/mist/ui_lib.go b/mist/ui_lib.go
index 334442f9f..a913af7db 100644
--- a/mist/ui_lib.go
+++ b/mist/ui_lib.go
@@ -37,7 +37,6 @@ type UiLib struct {
jsEngine *javascript.JSRE
filterCallbacks map[int][]int
- //filters map[int]*ethpipe.JSFilter
}
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
@@ -201,7 +200,7 @@ func (self *UiLib) UninstallFilter(id int) {
self.eth.UninstallFilter(id)
}
-func (self *UiLib) Transact(object map[string]interface{}) (*ethpipe.JSReceipt, error) {
+func mapToTxParams(object map[string]interface{}) map[string]string {
// Default values
if object["from"] == nil {
object["from"] = ""
@@ -223,6 +222,8 @@ func (self *UiLib) Transact(object map[string]interface{}) (*ethpipe.JSReceipt,
var data []string
if list, ok := object["data"].(*qml.List); ok {
list.Convert(&data)
+ } else if str, ok := object["data"].(string); ok {
+ data = []string{str}
}
for _, str := range data {
@@ -238,14 +239,29 @@ func (self *UiLib) Transact(object map[string]interface{}) (*ethpipe.JSReceipt,
dataStr += str
}
+ object["data"] = dataStr
+ fmt.Println(object)
+
+ conv := make(map[string]string)
+ for key, value := range object {
+ if v, ok := value.(string); ok {
+ conv[key] = v
+ }
+ }
+
+ return conv
+}
+
+func (self *UiLib) Transact(params map[string]interface{}) (*ethpipe.JSReceipt, error) {
+ object := mapToTxParams(params)
return self.JSPipe.Transact(
- object["from"].(string),
- object["to"].(string),
- object["value"].(string),
- object["gas"].(string),
- object["gasPrice"].(string),
- dataStr,
+ object["from"],
+ object["to"],
+ object["value"],
+ object["gas"],
+ object["gasPrice"],
+ object["data"],
)
}
@@ -257,3 +273,15 @@ func (self *UiLib) Compile(code string) (string, error) {
return ethutil.Bytes2Hex(bcode), err
}
+
+func (self *UiLib) Call(params map[string]interface{}) (string, error) {
+ object := mapToTxParams(params)
+
+ return self.JSPipe.Execute(
+ object["to"],
+ object["value"],
+ object["gas"],
+ object["gasPrice"],
+ object["data"],
+ )
+}