diff options
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/types.go | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/javascript/types.go b/javascript/types.go index ce1d9995a..61a57033b 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -72,15 +72,21 @@ type JSEthereum struct { ethereum *eth.Ethereum } -func (self *JSEthereum) GetBlock(hash string) otto.Value { - return self.toVal(&JSBlock{self.JSXEth.BlockByHash(hash), self}) +func (self *JSEthereum) Block(v interface{}) otto.Value { + if number, ok := v.(int64); ok { + return self.toVal(&JSBlock{self.JSXEth.BlockByNumber(int32(number)), self}) + } else if hash, ok := v.(string); ok { + return self.toVal(&JSBlock{self.JSXEth.BlockByHash(hash), self}) + } + + return otto.UndefinedValue() } -func (self *JSEthereum) GetPeers() otto.Value { +func (self *JSEthereum) Peers() otto.Value { return self.toVal(self.JSXEth.Peers()) } -func (self *JSEthereum) GetKey() otto.Value { +func (self *JSEthereum) Key() otto.Value { return self.toVal(self.JSXEth.Key()) } @@ -88,10 +94,6 @@ func (self *JSEthereum) GetStateObject(addr string) otto.Value { return self.toVal(&JSStateObject{xeth.NewJSObject(self.JSXEth.World().SafeGet(ethutil.Hex2Bytes(addr))), self}) } -func (self *JSEthereum) Peers() otto.Value { - return self.toVal(self.JSXEth.Peers()) -} - func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value { r, err := self.JSXEth.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr) if err != nil { @@ -103,18 +105,6 @@ func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, return self.toVal(r) } -func (self *JSEthereum) Create(key, valueStr, gasStr, gasPriceStr, scriptStr string) otto.Value { - r, err := self.JSXEth.Transact(key, "", valueStr, gasStr, gasPriceStr, scriptStr) - - if err != nil { - fmt.Println(err) - - return otto.UndefinedValue() - } - - return self.toVal(r) -} - func (self *JSEthereum) toVal(v interface{}) otto.Value { result, err := self.vm.ToValue(v) |