Merge branch 'release/poc5-rc12'
This commit is contained in:
commit
aa8a86f0a6
|
@ -5,7 +5,7 @@ Ethereum
|
||||||
|
|
||||||
Ethereum Go Client © 2014 Jeffrey Wilcke.
|
Ethereum Go Client © 2014 Jeffrey Wilcke.
|
||||||
|
|
||||||
Current state: Proof of Concept 5.0 RC11.
|
Current state: Proof of Concept 5.0 RC12.
|
||||||
|
|
||||||
For the development package please see the [eth-go package](https://github.com/ethereum/eth-go).
|
For the development package please see the [eth-go package](https://github.com/ethereum/eth-go).
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ ApplicationWindow {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width
|
width: parent.width
|
||||||
TableViewColumn{ id: key ; role: "key" ; title: "#" ; width: storageTableView.width / 2}
|
TableViewColumn{ id: key ; role: "key" ; title: "#" ; width: storageTableView.width / 2}
|
||||||
TableViewColumn{ role: "value" ; title: "value" ; width: storageTableView.width / 2}
|
TableViewColumn{ role: "value" ; title: "Storage" ; width: storageTableView.width / 2}
|
||||||
model: storageModel
|
model: storageModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,10 @@ window.eth = {
|
||||||
postData({call: "getStorage", args: [address, storageAddress]}, cb);
|
postData({call: "getStorage", args: [address, storageAddress]}, cb);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getStateKeyVals: function(address, cb){
|
||||||
|
postData({call: "getStateKeyVals", args: [address]}, cb);
|
||||||
|
},
|
||||||
|
|
||||||
getKey: function(cb) {
|
getKey: function(cb) {
|
||||||
postData({call: "getKey"}, cb);
|
postData({call: "getKey"}, cb);
|
||||||
},
|
},
|
||||||
|
|
|
@ -45,6 +45,13 @@ ApplicationWindow {
|
||||||
addPeerWin.visible = true
|
addPeerWin.visible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MenuItem {
|
||||||
|
text: "Show Peers"
|
||||||
|
shortcut: "Ctrl+e"
|
||||||
|
onTriggered: {
|
||||||
|
peerWindow.visible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
|
@ -247,13 +254,12 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
property var addressModel: ListModel {
|
property var addressModel: ListModel {
|
||||||
id: addressModel
|
id: addressModel
|
||||||
}
|
}
|
||||||
TableView {
|
TableView {
|
||||||
id: addressView
|
id: addressView
|
||||||
width: parent.width
|
width: parent.width - 200
|
||||||
height: 200
|
height: 200
|
||||||
anchors.bottom: logView.top
|
anchors.bottom: logView.top
|
||||||
TableViewColumn{ role: "name"; title: "name" }
|
TableViewColumn{ role: "name"; title: "name" }
|
||||||
|
@ -262,6 +268,30 @@ ApplicationWindow {
|
||||||
model: addressModel
|
model: addressModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.top: addressView.top
|
||||||
|
anchors.left: addressView.right
|
||||||
|
anchors.leftMargin: 20
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
placeholderText: "Name to register"
|
||||||
|
id: nameToReg
|
||||||
|
width: 150
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
anchors.top: nameToReg.bottom
|
||||||
|
text: "Register"
|
||||||
|
MouseArea{
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
eth.registerName(nameToReg.text)
|
||||||
|
nameToReg.text = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
property var logModel: ListModel {
|
property var logModel: ListModel {
|
||||||
id: logModel
|
id: logModel
|
||||||
|
@ -359,6 +389,10 @@ ApplicationWindow {
|
||||||
id: peerImage
|
id: peerImage
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
width: 10; height: 10
|
width: 10; height: 10
|
||||||
|
MouseArea {
|
||||||
|
onDoubleClicked: peerWindow.visible = true
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
source: ui.assetPath("network.png")
|
source: ui.assetPath("network.png")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -623,6 +657,20 @@ ApplicationWindow {
|
||||||
function setPeers(text) {
|
function setPeers(text) {
|
||||||
peerLabel.text = text
|
peerLabel.text = text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addPeer(peer) {
|
||||||
|
// We could just append the whole peer object but it cries if you try to alter them
|
||||||
|
peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), latency: peer.latency, version: peer.version})
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetPeers(){
|
||||||
|
peerModel.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
function timeAgo(unixTs){
|
||||||
|
var lapsed = (Date.now() - new Date(unixTs*1000)) / 1000
|
||||||
|
return (lapsed + " seconds ago")
|
||||||
|
}
|
||||||
function convertToPretty(unixTs){
|
function convertToPretty(unixTs){
|
||||||
var a = new Date(unixTs*1000);
|
var a = new Date(unixTs*1000);
|
||||||
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
||||||
|
@ -635,6 +683,31 @@ ApplicationWindow {
|
||||||
var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
|
var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
// ******************************************
|
||||||
|
// Windows
|
||||||
|
// ******************************************
|
||||||
|
Window {
|
||||||
|
id: peerWindow
|
||||||
|
height: 200
|
||||||
|
width: 700
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
property var peerModel: ListModel {
|
||||||
|
id: peerModel
|
||||||
|
}
|
||||||
|
TableView {
|
||||||
|
anchors.fill: parent
|
||||||
|
id: peerTable
|
||||||
|
model: peerModel
|
||||||
|
TableViewColumn{width: 100; role: "ip" ; title: "IP" }
|
||||||
|
TableViewColumn{width: 60; role: "port" ; title: "Port" }
|
||||||
|
TableViewColumn{width: 140; role: "lastResponse"; title: "Last event" }
|
||||||
|
TableViewColumn{width: 100; role: "latency"; title: "Latency" }
|
||||||
|
TableViewColumn{width: 260; role: "version" ; title: "Version" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// *******************************************
|
// *******************************************
|
||||||
// Components
|
// Components
|
||||||
// *******************************************
|
// *******************************************
|
||||||
|
@ -810,7 +883,6 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// New Transaction component
|
// New Transaction component
|
||||||
Component {
|
Component {
|
||||||
id: newTransaction
|
id: newTransaction
|
||||||
|
|
|
@ -34,7 +34,6 @@ ApplicationWindow {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
onTitleChanged: { window.title = title }
|
onTitleChanged: { window.title = title }
|
||||||
experimental.preferences.javascriptEnabled: true
|
experimental.preferences.javascriptEnabled: true
|
||||||
experimental.preferences.navigatorQtObjectEnabled: true
|
experimental.preferences.navigatorQtObjectEnabled: true
|
||||||
|
@ -97,6 +96,12 @@ ApplicationWindow {
|
||||||
var storage = stateObject.getStorage(data.args[1])
|
var storage = stateObject.getStorage(data.args[1])
|
||||||
postData(data._seed, storage)
|
postData(data._seed, storage)
|
||||||
|
|
||||||
|
break
|
||||||
|
case "getStateKeyVals":
|
||||||
|
require(1);
|
||||||
|
var stateObject = eth.getStateObject(data.args[0]).stateKeyVal(true)
|
||||||
|
postData(data._seed,stateObject)
|
||||||
|
|
||||||
break
|
break
|
||||||
case "getBalance":
|
case "getBalance":
|
||||||
require(1);
|
require(1);
|
||||||
|
@ -188,7 +193,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
WebView {
|
WebView {
|
||||||
id: inspector
|
id: inspector
|
||||||
visible: false
|
visible: true
|
||||||
url: webview.experimental.remoteInspectorUrl
|
url: webview.experimental.remoteInspectorUrl
|
||||||
anchors {
|
anchors {
|
||||||
left: root.left
|
left: root.left
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/ethereum/eth-go/ethchain"
|
"github.com/ethereum/eth-go/ethchain"
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"github.com/go-qml/qml"
|
"github.com/go-qml/qml"
|
||||||
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
win := component.CreateWindow(nil)
|
win := component.CreateWindow(nil)
|
||||||
db := &Debugger{win, make(chan bool), make(chan bool), true}
|
db := &Debugger{win, make(chan bool), make(chan bool), true, false}
|
||||||
|
|
||||||
return &DebuggerWindow{engine: engine, win: win, lib: lib, Db: db}
|
return &DebuggerWindow{engine: engine, win: win, lib: lib, Db: db}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +60,12 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
|
||||||
self.Db.Q <- true
|
self.Db.Q <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
self.Logf("compile FAULT: %v", r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
data := ethutil.StringToByteFunc(dataStr, func(s string) (ret []byte) {
|
data := ethutil.StringToByteFunc(dataStr, func(s string) (ret []byte) {
|
||||||
slice := strings.Split(dataStr, "\n")
|
slice := strings.Split(dataStr, "\n")
|
||||||
for _, dataItem := range slice {
|
for _, dataItem := range slice {
|
||||||
|
@ -89,15 +96,17 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
|
||||||
self.win.Root().Call("setAsm", str)
|
self.win.Root().Call("setAsm", str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gas := ethutil.Big(gasStr)
|
||||||
|
gasPrice := ethutil.Big(gasPriceStr)
|
||||||
// Contract addr as test address
|
// Contract addr as test address
|
||||||
keyPair := ethutil.GetKeyRing().Get(0)
|
keyPair := ethutil.GetKeyRing().Get(0)
|
||||||
callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), script)
|
callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), gas, gasPrice, script)
|
||||||
callerTx.Sign(keyPair.PrivateKey)
|
callerTx.Sign(keyPair.PrivateKey)
|
||||||
|
|
||||||
state := self.lib.eth.BlockChain().CurrentBlock.State()
|
state := self.lib.eth.BlockChain().CurrentBlock.State()
|
||||||
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
|
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
|
||||||
contract := ethchain.MakeContract(callerTx, state)
|
contract := ethchain.MakeContract(callerTx, state)
|
||||||
callerClosure := ethchain.NewClosure(account, contract, script, state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))
|
callerClosure := ethchain.NewClosure(account, contract, script, state, gas, gasPrice)
|
||||||
|
|
||||||
block := self.lib.eth.BlockChain().CurrentBlock
|
block := self.lib.eth.BlockChain().CurrentBlock
|
||||||
vm := ethchain.NewVm(state, self.lib.eth.StateManager(), ethchain.RuntimeVars{
|
vm := ethchain.NewVm(state, self.lib.eth.StateManager(), ethchain.RuntimeVars{
|
||||||
|
@ -111,17 +120,28 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
|
||||||
})
|
})
|
||||||
|
|
||||||
self.Db.done = false
|
self.Db.done = false
|
||||||
|
self.Logf("callsize %d", len(script))
|
||||||
go func() {
|
go func() {
|
||||||
ret, _, err := callerClosure.Call(vm, data, self.Db.halting)
|
ret, g, err := callerClosure.Call(vm, data, self.Db.halting)
|
||||||
|
tot := new(big.Int).Mul(g, gasPrice)
|
||||||
|
self.Logf("gas usage %v total price = %v (%v)", g, tot, ethutil.CurrencyToString(tot))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
self.Logln("exited with errors:", err)
|
self.Logln("exited with errors:", err)
|
||||||
} else {
|
} else {
|
||||||
self.Logf("exited: %v", ret)
|
if len(ret) > 0 {
|
||||||
|
self.Logf("exited: % x", ret)
|
||||||
|
} else {
|
||||||
|
self.Logf("exited: nil")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.Reset()
|
state.Reset()
|
||||||
|
|
||||||
self.Db.done = true
|
if !self.Db.interrupt {
|
||||||
|
self.Db.done = true
|
||||||
|
} else {
|
||||||
|
self.Db.interrupt = false
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,10 +159,10 @@ func (self *DebuggerWindow) Next() {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Debugger struct {
|
type Debugger struct {
|
||||||
win *qml.Window
|
win *qml.Window
|
||||||
N chan bool
|
N chan bool
|
||||||
Q chan bool
|
Q chan bool
|
||||||
done bool
|
done, interrupt bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type storeVal struct {
|
type storeVal struct {
|
||||||
|
@ -175,7 +195,8 @@ out:
|
||||||
case <-d.N:
|
case <-d.N:
|
||||||
break out
|
break out
|
||||||
case <-d.Q:
|
case <-d.Q:
|
||||||
d.done = true
|
d.interrupt = true
|
||||||
|
d.clearBuffers()
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -184,6 +205,19 @@ out:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Debugger) clearBuffers() {
|
||||||
|
out:
|
||||||
|
// drain
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-d.N:
|
||||||
|
case <-d.Q:
|
||||||
|
default:
|
||||||
|
break out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Debugger) Next() {
|
func (d *Debugger) Next() {
|
||||||
if !d.done {
|
if !d.done {
|
||||||
d.N <- true
|
d.N <- true
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/go-qml/qml"
|
"github.com/go-qml/qml"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Gui struct {
|
type Gui struct {
|
||||||
|
@ -55,7 +56,7 @@ func New(ethereum *eth.Ethereum) *Gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) Start(assetPath string) {
|
func (gui *Gui) Start(assetPath string) {
|
||||||
const version = "0.5.0 RC11"
|
const version = "0.5.0 RC12"
|
||||||
|
|
||||||
defer gui.txDb.Close()
|
defer gui.txDb.Close()
|
||||||
|
|
||||||
|
@ -64,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.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.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))
|
ethutil.Config.SetClientString(fmt.Sprintf("/Ethereal v%s", version))
|
||||||
|
@ -91,7 +94,7 @@ func (gui *Gui) Start(assetPath string) {
|
||||||
ethutil.Config.Log.AddLogSystem(gui)
|
ethutil.Config.Log.AddLogSystem(gui)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ethutil.Config.Log.Infoln("FATAL: asset not found: you can set an alternative asset path on on the command line using option 'asset_path'")
|
ethutil.Config.Log.Infoln("FATAL: asset not found: you can set an alternative asset path on on the command line using option 'asset_path'", err)
|
||||||
|
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -151,7 +154,7 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window {
|
||||||
gui.win = win
|
gui.win = win
|
||||||
gui.uiLib.win = win
|
gui.uiLib.win = win
|
||||||
|
|
||||||
db := &Debugger{gui.win, make(chan bool), make(chan bool), true}
|
db := &Debugger{gui.win, make(chan bool), make(chan bool), true, false}
|
||||||
gui.lib.Db = db
|
gui.lib.Db = db
|
||||||
gui.uiLib.Db = db
|
gui.uiLib.Db = db
|
||||||
|
|
||||||
|
@ -162,6 +165,17 @@ func (gui *Gui) setInitialBlockChain() {
|
||||||
blk := gui.eth.BlockChain().GetBlock(sBlk)
|
blk := gui.eth.BlockChain().GetBlock(sBlk)
|
||||||
for ; blk != nil; blk = gui.eth.BlockChain().GetBlock(sBlk) {
|
for ; blk != nil; blk = gui.eth.BlockChain().GetBlock(sBlk) {
|
||||||
sBlk = blk.PrevHash
|
sBlk = blk.PrevHash
|
||||||
|
|
||||||
|
// Loop through all transactions to see if we missed any while being offline
|
||||||
|
for _, tx := range blk.Transactions() {
|
||||||
|
if bytes.Compare(tx.Sender(), gui.addr) == 0 || bytes.Compare(tx.Recipient, gui.addr) == 0 {
|
||||||
|
if ok, _ := gui.txDb.Get(tx.Hash()); ok == nil {
|
||||||
|
gui.txDb.Put(tx.Hash(), tx.RlpEncode())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gui.processBlock(blk, true)
|
gui.processBlock(blk, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,6 +249,8 @@ func (gui *Gui) update() {
|
||||||
reactor.Subscribe("object:"+string(namereg), objectChan)
|
reactor.Subscribe("object:"+string(namereg), objectChan)
|
||||||
reactor.Subscribe("peerList", peerChan)
|
reactor.Subscribe("peerList", peerChan)
|
||||||
|
|
||||||
|
ticker := time.NewTicker(5 * time.Second)
|
||||||
|
|
||||||
state := gui.eth.StateManager().TransState()
|
state := gui.eth.StateManager().TransState()
|
||||||
|
|
||||||
unconfirmedFunds := new(big.Int)
|
unconfirmedFunds := new(big.Int)
|
||||||
|
@ -284,12 +300,19 @@ func (gui *Gui) update() {
|
||||||
gui.loadAddressBook()
|
gui.loadAddressBook()
|
||||||
case <-peerChan:
|
case <-peerChan:
|
||||||
gui.setPeerInfo()
|
gui.setPeerInfo()
|
||||||
|
case <-ticker.C:
|
||||||
|
gui.setPeerInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) setPeerInfo() {
|
func (gui *Gui) setPeerInfo() {
|
||||||
gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
|
gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
|
||||||
|
|
||||||
|
gui.win.Root().Call("resetPeers")
|
||||||
|
for _, peer := range gui.pub.GetPeers() {
|
||||||
|
gui.win.Root().Call("addPeer", peer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logging functions that log directly to the GUI interface
|
// Logging functions that log directly to the GUI interface
|
||||||
|
@ -308,6 +331,11 @@ func (gui *Gui) Printf(format string, v ...interface{}) {
|
||||||
gui.win.Root().Call("addLog", line)
|
gui.win.Root().Call("addLog", line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (gui *Gui) RegisterName(name string) {
|
||||||
|
keyPair := ethutil.GetKeyRing().Get(0)
|
||||||
|
name = fmt.Sprintf("\"%s\"\n1", name)
|
||||||
|
gui.pub.Transact(ethutil.Hex(keyPair.PrivateKey), "namereg", "1000", "1000000", "150", name)
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) Transact(recipient, value, gas, gasPrice, data string) (*ethpub.PReceipt, error) {
|
func (gui *Gui) Transact(recipient, value, gas, gasPrice, data string) (*ethpub.PReceipt, error) {
|
||||||
keyPair := ethutil.GetKeyRing().Get(0)
|
keyPair := ethutil.GetKeyRing().Get(0)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/obscuren/otto"
|
"github.com/obscuren/otto"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -25,6 +26,20 @@ type JSRE struct {
|
||||||
objectCb map[string][]otto.Value
|
objectCb map[string][]otto.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (jsre *JSRE) LoadExtFile(path string) {
|
||||||
|
result, err := ioutil.ReadFile(path)
|
||||||
|
if err == nil {
|
||||||
|
jsre.vm.Run(result)
|
||||||
|
} else {
|
||||||
|
ethutil.Config.Log.Debugln("Could not load file:", path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (jsre *JSRE) LoadIntFile(file string) {
|
||||||
|
assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "ethereal", "assets", "ext")
|
||||||
|
jsre.LoadExtFile(path.Join(assetPath, file))
|
||||||
|
}
|
||||||
|
|
||||||
func NewJSRE(ethereum *eth.Ethereum) *JSRE {
|
func NewJSRE(ethereum *eth.Ethereum) *JSRE {
|
||||||
re := &JSRE{
|
re := &JSRE{
|
||||||
ethereum,
|
ethereum,
|
||||||
|
@ -39,6 +54,10 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
|
||||||
// Init the JS lib
|
// Init the JS lib
|
||||||
re.vm.Run(jsLib)
|
re.vm.Run(jsLib)
|
||||||
|
|
||||||
|
// Load extra javascript files
|
||||||
|
re.LoadIntFile("string.js")
|
||||||
|
re.LoadIntFile("big.js")
|
||||||
|
|
||||||
// We have to make sure that, whoever calls this, calls "Stop"
|
// We have to make sure that, whoever calls this, calls "Stop"
|
||||||
go re.mainLoop()
|
go re.mainLoop()
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,10 @@ func (self *JSEthereum) GetBlock(hash string) otto.Value {
|
||||||
return self.toVal(&JSBlock{self.PEthereum.GetBlock(hash), self})
|
return self.toVal(&JSBlock{self.PEthereum.GetBlock(hash), self})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *JSEthereum) GetPeers() otto.Value {
|
||||||
|
return self.toVal(self.PEthereum.GetPeers())
|
||||||
|
}
|
||||||
|
|
||||||
func (self *JSEthereum) GetKey() otto.Value {
|
func (self *JSEthereum) GetKey() otto.Value {
|
||||||
return self.toVal(self.PEthereum.GetKey())
|
return self.toVal(self.PEthereum.GetKey())
|
||||||
}
|
}
|
||||||
|
@ -74,6 +78,10 @@ func (self *JSEthereum) GetStateObject(addr string) otto.Value {
|
||||||
return self.toVal(self.PEthereum.GetStateObject(addr))
|
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 {
|
func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value {
|
||||||
r, err := self.PEthereum.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr)
|
r, err := self.PEthereum.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -101,7 +109,7 @@ func (self *JSEthereum) toVal(v interface{}) otto.Value {
|
||||||
result, err := self.vm.ToValue(v)
|
result, err := self.vm.ToValue(v)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println("Value unknown:", err)
|
||||||
|
|
||||||
return otto.UndefinedValue()
|
return otto.UndefinedValue()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue