From d35380c19e5ce92b57158e7780f7105dc4136916 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 23 May 2014 14:37:03 +0200 Subject: [PATCH 1/3] New main script through init return value --- ethereal/ui/gui.go | 5 ++--- ethereal/ui/ui_lib.go | 2 +- ethereum/config.go | 3 +-- ethereum/repl.go | 15 ++++++++++++--- ethereum/repl_darwin.go | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index 7290bd6ec4..022f192bf7 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -9,7 +9,6 @@ import ( "github.com/ethereum/eth-go/ethpub" "github.com/ethereum/eth-go/ethutil" "github.com/go-qml/qml" - "github.com/obscuren/mutan" "math/big" "strings" ) @@ -262,7 +261,7 @@ func (gui *Gui) Transact(recipient, value, gas, gasPrice, data string) (*ethpub. func (gui *Gui) Create(recipient, value, gas, gasPrice, data string) (*ethpub.PReceipt, error) { keyPair := ethutil.GetKeyRing().Get(0) - mainInput, initInput := mutan.PreParse(data) + //mainInput, initInput := mutan.PreParse(data) - return gui.pub.Create(ethutil.Hex(keyPair.PrivateKey), value, gas, gasPrice, initInput, mainInput) + return gui.pub.Create(ethutil.Hex(keyPair.PrivateKey), value, gas, gasPrice, data) } diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go index 0c43f1675b..1c88b01818 100644 --- a/ethereal/ui/ui_lib.go +++ b/ethereal/ui/ui_lib.go @@ -135,7 +135,7 @@ func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) for _, str := range dis { ui.win.Root().Call("setAsm", str) } - callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), callerScript, nil) + callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), nil) // Contract addr as test address keyPair := ethutil.GetKeyRing().Get(0) diff --git a/ethereum/config.go b/ethereum/config.go index f39f3b7da1..5da910f2bd 100644 --- a/ethereum/config.go +++ b/ethereum/config.go @@ -31,7 +31,7 @@ func Init() { flag.PrintDefaults() } - flag.StringVar(&Identifier, "i", "", "Custom client identifier") + flag.StringVar(&Identifier, "i", "", "custom client identifier") flag.BoolVar(&StartMining, "m", false, "start dagger mining") flag.BoolVar(&ShowGenesis, "g", false, "prints genesis header and exits") flag.BoolVar(&StartRpc, "r", false, "start rpc server") @@ -47,7 +47,6 @@ func Init() { flag.StringVar(&ImportKey, "import", "", "imports the given private key (hex)") flag.IntVar(&MaxPeer, "x", 10, "maximum desired peers") flag.BoolVar(&StartJsConsole, "js", false, "exp") - //flag.StringVar(&InputFile, "e", "", "Run javascript file") flag.Parse() diff --git a/ethereum/repl.go b/ethereum/repl.go index d1243d19c2..10f51675eb 100644 --- a/ethereum/repl.go +++ b/ethereum/repl.go @@ -48,13 +48,22 @@ func (self *JSRepl) parseInput(code string) { // The JSEthereum object attempts to wrap the PEthereum object and returns // meaningful javascript objects +type JSBlock struct { + *ethpub.PBlock + eth *JSEthereum +} + +func (self *JSBlock) GetTransaction(hash string) otto.Value { + return self.eth.toVal(self.PBlock.GetTransaction(hash)) +} + type JSEthereum struct { *ethpub.PEthereum vm *otto.Otto } func (self *JSEthereum) GetBlock(hash string) otto.Value { - return self.toVal(self.PEthereum.GetBlock(hash)) + return self.toVal(&JSBlock{self.PEthereum.GetBlock(hash), self}) } func (self *JSEthereum) GetKey() otto.Value { @@ -76,8 +85,8 @@ func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, return self.toVal(r) } -func (self *JSEthereum) Create(key, valueStr, gasStr, gasPriceStr, initStr, bodyStr string) otto.Value { - r, err := self.PEthereum.Create(key, valueStr, gasStr, gasPriceStr, initStr, bodyStr) +func (self *JSEthereum) Create(key, valueStr, gasStr, gasPriceStr, scriptStr string) otto.Value { + r, err := self.PEthereum.Create(key, valueStr, gasStr, gasPriceStr, scriptStr) if err != nil { fmt.Println(err) diff --git a/ethereum/repl_darwin.go b/ethereum/repl_darwin.go index fa36b0d526..b61d4edd7e 100644 --- a/ethereum/repl_darwin.go +++ b/ethereum/repl_darwin.go @@ -102,7 +102,7 @@ L: break L } - addHistory(str) //allow user to recall this line + addHistory(str[:len(str)-1]) //allow user to recall this line self.parseInput(str) From b42c70be9c669ba372ed99d820a5a9e807191619 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 26 May 2014 00:10:38 +0200 Subject: [PATCH 2/3] Recv send for txs --- ethereal/assets/qml/wallet.qml | 9 ++++----- ethereal/ui/gui.go | 16 +++++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml index 51f064adf1..f23f182f3c 100644 --- a/ethereal/assets/qml/wallet.qml +++ b/ethereal/assets/qml/wallet.qml @@ -85,7 +85,6 @@ ApplicationWindow { //color: "#D9DDE7" color: "#252525" - ColumnLayout { y: 50 anchors.left: parent.left @@ -155,6 +154,7 @@ ApplicationWindow { TableView { id: txTableView anchors.fill: parent + TableViewColumn{ role: "inout" ; title: "" ; width: 40 } TableViewColumn{ role: "value" ; title: "Value" ; width: 100 } TableViewColumn{ role: "address" ; title: "Address" ; width: 430 } TableViewColumn{ role: "contract" ; title: "Contract" ; width: 100 } @@ -404,7 +404,7 @@ ApplicationWindow { anchors.left: aboutIcon.right anchors.leftMargin: 10 font.pointSize: 12 - text: "

Ethereal


Development

Jeffrey Wilcke
Maran Hidskes

Binary Distribution

Jarrad Hope
" + text: "

Ethereal


Development

Jeffrey Wilcke
Maran Hidskes
" } } @@ -429,7 +429,6 @@ ApplicationWindow { } } SplitView { - anchors.fill: parent property var asmModel: ListModel { id: asmModel @@ -524,14 +523,14 @@ ApplicationWindow { walletValueLabel.text = value } - function addTx(tx) { + function addTx(tx, inout) { var isContract if (tx.contract == true){ isContract = "Yes" }else{ isContract = "No" } - txModel.insert(0, {hash: tx.hash, address: tx.address, value: tx.value, contract: isContract}) + txModel.insert(0, {inout: inout, hash: tx.hash, address: tx.address, value: tx.value, contract: isContract}) } function addBlock(block) { diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index 022f192bf7..a8bfb2b581 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -151,7 +151,15 @@ func (gui *Gui) readPreviousTransactions() { for it.Next() { tx := ethchain.NewTransactionFromBytes(it.Value()) - gui.win.Root().Call("addTx", ethpub.NewPTx(tx)) + var inout string + if bytes.Compare(tx.Sender(), gui.addr) == 0 { + inout = "send" + } else { + inout = "recv" + } + + gui.win.Root().Call("addTx", ethpub.NewPTx(tx), inout) + } it.Release() } @@ -207,12 +215,12 @@ func (gui *Gui) update() { object := state.GetAccount(gui.addr) if bytes.Compare(tx.Sender(), gui.addr) == 0 { - gui.win.Root().Call("addTx", ethpub.NewPTx(tx)) + gui.win.Root().Call("addTx", ethpub.NewPTx(tx), "send") gui.txDb.Put(tx.Hash(), tx.RlpEncode()) unconfirmedFunds.Sub(unconfirmedFunds, tx.Value) } else if bytes.Compare(tx.Recipient, gui.addr) == 0 { - gui.win.Root().Call("addTx", ethpub.NewPTx(tx)) + gui.win.Root().Call("addTx", ethpub.NewPTx(tx), "recv") gui.txDb.Put(tx.Hash(), tx.RlpEncode()) unconfirmedFunds.Add(unconfirmedFunds, tx.Value) @@ -261,7 +269,5 @@ func (gui *Gui) Transact(recipient, value, gas, gasPrice, data string) (*ethpub. func (gui *Gui) Create(recipient, value, gas, gasPrice, data string) (*ethpub.PReceipt, error) { keyPair := ethutil.GetKeyRing().Get(0) - //mainInput, initInput := mutan.PreParse(data) - return gui.pub.Create(ethutil.Hex(keyPair.PrivateKey), value, gas, gasPrice, data) } From 818bc84591c490b29cb28ee1e4895c8f303a0af1 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 26 May 2014 00:39:05 +0200 Subject: [PATCH 3/3] Bump --- README.md | 2 +- ethereal/ui/gui.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e5818ffcab..6c19be9aa1 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Ethereum Ethereum Go Client © 2014 Jeffrey Wilcke. -Current state: Proof of Concept 5.0 RC8. +Current state: Proof of Concept 5.0 RC9. For the development package please see the [eth-go package](https://github.com/ethereum/eth-go). diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index a8bfb2b581..8d6796ddbb 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -54,7 +54,7 @@ func New(ethereum *eth.Ethereum) *Gui { } func (gui *Gui) Start(assetPath string) { - const version = "0.5.0 RC8" + const version = "0.5.0 RC9" defer gui.txDb.Close()