From f15d23b49686d2325885bee663bc49b7563f689c Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 28 Jan 2015 10:47:17 +0100 Subject: updated messages --- javascript/types.go | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'javascript') diff --git a/javascript/types.go b/javascript/types.go index 61a57033b..d85e24c88 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -38,31 +38,19 @@ func (self *JSBlock) GetTransaction(hash string) otto.Value { return self.eth.toVal(self.JSBlock.GetTransaction(hash)) } -type JSMessage struct { - To string `json:"to"` - From string `json:"from"` - Input string `json:"input"` - Output string `json:"output"` - Path int `json:"path"` - Origin string `json:"origin"` - Timestamp int32 `json:"timestamp"` - Coinbase string `json:"coinbase"` - Block string `json:"block"` - Number int32 `json:"number"` +type JSLog struct { + Address string `json:address` + Topics []string `json:topics` + Number int32 `json:number` + Data string `json:data` } -func NewJSMessage(message *state.Message) JSMessage { - return JSMessage{ - To: ethutil.Bytes2Hex(message.To), - From: ethutil.Bytes2Hex(message.From), - Input: ethutil.Bytes2Hex(message.Input), - Output: ethutil.Bytes2Hex(message.Output), - Path: message.Path, - Origin: ethutil.Bytes2Hex(message.Origin), - Timestamp: int32(message.Timestamp), - Coinbase: ethutil.Bytes2Hex(message.Origin), - Block: ethutil.Bytes2Hex(message.Block), - Number: int32(message.Number.Int64()), +func NewJSLog(log state.Log) JSLog { + return JSLog{ + Address: ethutil.Bytes2Hex(log.Address()), + Topics: nil, //ethutil.Bytes2Hex(log.Address()), + Number: 0, + Data: ethutil.Bytes2Hex(log.Data()), } } @@ -120,13 +108,13 @@ func (self *JSEthereum) toVal(v interface{}) otto.Value { func (self *JSEthereum) Messages(object map[string]interface{}) otto.Value { filter := ui.NewFilterFromMap(object, self.ethereum) - messages := filter.Find() - var msgs []JSMessage - for _, m := range messages { - msgs = append(msgs, NewJSMessage(m)) + logs := filter.Find() + var jslogs []JSLog + for _, m := range logs { + jslogs = append(jslogs, NewJSLog(m)) } - v, _ := self.vm.ToValue(msgs) + v, _ := self.vm.ToValue(jslogs) return v } -- cgit From 7f638f0b2d8d989be25e660178d79df3278e4c84 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 28 Jan 2015 18:14:28 +0100 Subject: moving to a better xeth --- javascript/types.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'javascript') diff --git a/javascript/types.go b/javascript/types.go index 61a57033b..3f30fa92b 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -82,16 +82,8 @@ func (self *JSEthereum) Block(v interface{}) otto.Value { return otto.UndefinedValue() } -func (self *JSEthereum) Peers() otto.Value { - return self.toVal(self.JSXEth.Peers()) -} - -func (self *JSEthereum) Key() otto.Value { - return self.toVal(self.JSXEth.Key()) -} - func (self *JSEthereum) GetStateObject(addr string) otto.Value { - return self.toVal(&JSStateObject{xeth.NewJSObject(self.JSXEth.World().SafeGet(ethutil.Hex2Bytes(addr))), self}) + return self.toVal(&JSStateObject{xeth.NewJSObject(self.JSXEth.State().SafeGet(addr)), self}) } func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value { -- cgit From 872b2497114209119becf2e8a4d4a5818e2084ee Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 28 Jan 2015 18:35:49 +0100 Subject: further cleaned up xeth interface --- javascript/javascript_runtime.go | 4 ++-- javascript/types.go | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index adc9022b7..c780eb754 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -24,7 +24,7 @@ var jsrelogger = logger.NewLogger("JSRE") type JSRE struct { ethereum *eth.Ethereum Vm *otto.Otto - pipe *xeth.JSXEth + pipe *xeth.XEth events event.Subscription @@ -49,7 +49,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { re := &JSRE{ ethereum, otto.New(), - xeth.NewJSXEth(ethereum), + xeth.New(ethereum), nil, make(map[string][]otto.Value), } diff --git a/javascript/types.go b/javascript/types.go index 3f30fa92b..7fb2082b9 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -12,14 +12,14 @@ import ( ) type JSStateObject struct { - *xeth.JSObject + *xeth.Object eth *JSEthereum } func (self *JSStateObject) EachStorage(call otto.FunctionCall) otto.Value { cb := call.Argument(0) - it := self.JSObject.Trie().Iterator() + it := self.Object.Trie().Iterator() for it.Next() { cb.Call(self.eth.toVal(self), self.eth.toVal(ethutil.Bytes2Hex(it.Key)), self.eth.toVal(ethutil.Bytes2Hex(it.Value))) } @@ -30,12 +30,12 @@ func (self *JSStateObject) EachStorage(call otto.FunctionCall) otto.Value { // The JSEthereum object attempts to wrap the PEthereum object and returns // meaningful javascript objects type JSBlock struct { - *xeth.JSBlock + *xeth.Block eth *JSEthereum } func (self *JSBlock) GetTransaction(hash string) otto.Value { - return self.eth.toVal(self.JSBlock.GetTransaction(hash)) + return self.eth.toVal(self.Block.GetTransaction(hash)) } type JSMessage struct { @@ -67,27 +67,27 @@ func NewJSMessage(message *state.Message) JSMessage { } type JSEthereum struct { - *xeth.JSXEth + *xeth.XEth vm *otto.Otto ethereum *eth.Ethereum } func (self *JSEthereum) Block(v interface{}) otto.Value { if number, ok := v.(int64); ok { - return self.toVal(&JSBlock{self.JSXEth.BlockByNumber(int32(number)), self}) + return self.toVal(&JSBlock{self.XEth.BlockByNumber(int32(number)), self}) } else if hash, ok := v.(string); ok { - return self.toVal(&JSBlock{self.JSXEth.BlockByHash(hash), self}) + return self.toVal(&JSBlock{self.XEth.BlockByHash(hash), self}) } return otto.UndefinedValue() } func (self *JSEthereum) GetStateObject(addr string) otto.Value { - return self.toVal(&JSStateObject{xeth.NewJSObject(self.JSXEth.State().SafeGet(addr)), self}) + return self.toVal(&JSStateObject{self.XEth.State().SafeGet(addr), self}) } func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value { - r, err := self.JSXEth.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr) + r, err := self.XEth.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr) if err != nil { fmt.Println(err) -- cgit From cebb149f5cfaf008240d7069fd220401950cc7ee Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 28 Jan 2015 20:50:09 +0100 Subject: removed key while in the process of moving to the new key storage --- javascript/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'javascript') diff --git a/javascript/types.go b/javascript/types.go index 2ee5b39ba..17f1b739e 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -75,7 +75,7 @@ func (self *JSEthereum) GetStateObject(addr string) otto.Value { } func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value { - r, err := self.XEth.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr) + r, err := self.XEth.Transact(recipient, valueStr, gasStr, gasPriceStr, dataStr) if err != nil { fmt.Println(err) -- cgit From 84adf77bf3492351de82f0ec820a1d280e85a5cd Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 29 Jan 2015 13:10:34 +0100 Subject: Added RPC "Call" for JS calls to contracts --- javascript/javascript_runtime.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index c780eb754..398daf43a 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -58,8 +58,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { re.Vm.Run(jsLib) // Load extra javascript files - re.LoadIntFile("string.js") - re.LoadIntFile("big.js") + re.LoadIntFile("bignumber.min.js") // Subscribe to events mux := ethereum.EventMux() -- cgit From 56f777b2fc77275bc636562b66a08b19afe2ec56 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 5 Feb 2015 03:16:16 +0100 Subject: cmd/ethereum, cmd/mist, core, eth, javascript, xeth: fixes for new p2p API --- javascript/javascript_runtime.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 398daf43a..a09aff027 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/otto" @@ -201,8 +202,15 @@ func (self *JSRE) addPeer(call otto.FunctionCall) otto.Value { if err != nil { return otto.FalseValue() } - self.ethereum.SuggestPeer(host) - + idstr, err := call.Argument(0).ToString() + if err != nil { + return otto.FalseValue() + } + id, err := discover.HexID(idstr) + if err != nil { + return otto.FalseValue() + } + self.ethereum.SuggestPeer(host, id) return otto.TrueValue() } -- cgit From 2cf4fed11b01bb99e08b838f7df2b9396f42f758 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sat, 7 Feb 2015 00:15:04 +0100 Subject: cmd/mist, eth, javascript, p2p: use Node URLs for peer suggestions --- javascript/javascript_runtime.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index a09aff027..0aa0f73e2 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -14,7 +14,6 @@ import ( "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/otto" @@ -198,19 +197,13 @@ func (self *JSRE) watch(call otto.FunctionCall) otto.Value { } func (self *JSRE) addPeer(call otto.FunctionCall) otto.Value { - host, err := call.Argument(0).ToString() + nodeURL, err := call.Argument(0).ToString() if err != nil { return otto.FalseValue() } - idstr, err := call.Argument(0).ToString() - if err != nil { - return otto.FalseValue() - } - id, err := discover.HexID(idstr) - if err != nil { + if err := self.ethereum.SuggestPeer(nodeURL); err != nil { return otto.FalseValue() } - self.ethereum.SuggestPeer(host, id) return otto.TrueValue() } -- cgit