Merge branch 'develop' into feature/rpc

pull/84/head
Maran 11 years ago
commit 60f9966cd8
  1. 10
      README.md
  2. 66
      ethereal/assets/ethereum.js
  3. 9
      ethereal/assets/qml/webapp.qml
  4. 69
      ethereal/assets/samplecoin.html
  5. 7
      ethereal/assets/samplecoin/bootstrap-theme.min.css
  6. 7
      ethereal/assets/samplecoin/bootstrap.min.css
  7. 0
      ethereal/assets/samplecoin/icon.png
  8. 34
      ethereal/assets/samplecoin/samplecoin.css
  9. 70
      ethereal/assets/samplecoin/samplecoin.html
  10. 55
      ethereal/assets/test.html
  11. 96
      ethereal/ui/ext_app.go
  12. 13
      ethereal/ui/gui.go
  13. 5
      ethereal/ui/html_container.go
  14. 10
      ethereal/ui/library.go
  15. 110
      utils/ethereum.go
  16. 44
      utils/types.go

@ -12,7 +12,15 @@ For the development package please see the [eth-go package](https://github.com/e
Build
=======
For build instruction please see the [Wiki](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go))
To build Ethereal (GUI):
`go get github.com/ethereum/go-ethereum/ethereal`
To build the node (CLI):
`go get github.com/ethereum/go-ethereum/ethereum`
For further, detailed, build instruction please see the [Wiki](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum(Go))
General command line options
====================

@ -19,8 +19,7 @@ window.eth = {
// Create transaction
//
// Creates a transaction with the current account
// If no recipient is set, the Ethereum API will see it as a contract creation
// Transact between two state objects
transact: function(sec, recipient, value, gas, gasPrice, data, cb) {
postData({call: "transact", args: [sec, recipient, value, gas, gasPrice, data]}, cb);
},
@ -71,6 +70,10 @@ window.eth = {
postData({call: "disconnect", args: [address, storageAddrOrCb]});
},
set: function(props) {
postData({call: "set", args: props});
},
on: function(event, cb) {
if(eth._onCallbacks[event] === undefined) {
eth._onCallbacks[event] = [];
@ -110,7 +113,7 @@ function debug(/**/) {
var args = arguments;
var msg = ""
for(var i = 0; i < args.length; i++){
if(typeof args[i] == "object") {
if(typeof args[i] === "object") {
msg += " " + JSON.stringify(args[i])
} else {
msg += args[i]
@ -151,3 +154,60 @@ navigator.qt.onmessage = function(ev) {
}
}
}
window.eth._0 = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
String.prototype.pad = function(len) {
var bin = this.bin();
var l = bin.length;
if(l < 32) {
return eth._0.substr(0, 32 - bin.length) + bin;
}
return bin;
}
String.prototype.unpad = function() {
var i, l;
for(i = 0, l = this.length; i < l; i++) {
if(this[i] != "\0") {
return this.substr(i, this.length);
}
}
return this.substr(i, this.length);
}
String.prototype.bin = function() {
if(this.substr(0, 2) == "0x") {
return this.hex2bin();
} else if(/^\d+$/.test(this)) {
return this.num2bin()
}
// Otherwise we'll return the "String" object instead of an actual string
return this.substr(0, this.length)
}
String.prototype.unbin = function() {
var i, l, o = '';
for(i = 0, l = this.length; i < l; i++) {
var n = this.charCodeAt(i).toString(16);
o += n.length < 2 ? '0' + n : n;
}
return "0x" + o;
}
String.prototype.hex2bin = function() {
bytes = []
for(var i=2; i< this.length-1; i+=2) {
bytes.push(parseInt(this.substr(i, 2), 16));
}
return String.fromCharCode.apply(String, bytes);
}
String.prototype.num2bin = function() {
return ("0x"+parseInt(this).toString(16)).bin()
}

@ -60,6 +60,7 @@ ApplicationWindow {
var tx = eth.transact(data.args[0], data.args[1], data.args[2],data.args[3],data.args[4],data.args[5])
postData(data._seed, tx)
break
case "create":
postData(data._seed, null)
@ -91,6 +92,12 @@ ApplicationWindow {
require(1)
postData(data._seed, null)
break;
case "set":
for(var key in data.args) {
if(webview.hasOwnProperty(key)) {
window[key] = data.args[key];
}
}
}
} catch(e) {
console.log(data.call + ": " + e)
@ -117,6 +124,8 @@ ApplicationWindow {
function onObjectChangeCb(stateObject) {
postEvent("object:"+stateObject.address(), stateObject)
}
function onStorageChangeCb() {
}
}
Rectangle {

@ -1,69 +0,0 @@
<html>
<head>
<title>jeffcoin</title>
<script type="text/javascript">
var jefcoinAddr = "3dff537f51350239abc95c76a5864aa605259e7d"
function createTransaction() {
var addr = document.querySelector("#addr").value;
var amount = document.querySelector("#amount").value;
var data = "0x" + addr + "\n" + amount
eth.transact("", jefcoinAddr, 0, "10000000", "250", data, function(tx) {
debug("received tx hash:", tx)
})
}
// Any test related actions here please
function tests() {
eth.getKey(function(keys) {
debug(keys)
})
}
function init() {
eth.getKey(function(key) {
eth.getStorageAt(jefcoinAddr, key, function(storage) {
document.querySelector("#currentAmount").innerHTML = "Amount: " + storage;
});
eth.watch(jefcoinAddr, function(stateObject) {
eth.getStorageAt(jefcoinAddr, key, function(storage) {
document.querySelector("#currentAmount").innerHTML = "Amount: " + storage;
});
});
eth.getBalanceAt(key, function(balance) {
debug("balance", balance);
})
});
}
</script>
<style type="text/css">
input[type="text"] {
width: 300px;
}
</style>
</head>
<body onload="init();">
<h1>Jeff Coin</h1>
<img src="icon.png">
<div id="currentAmount"></div>
<div id="transactions">
<input id="addr" type="text" placeholder="Receiver address"></input><br>
<input id="amount" type="text" placeholder="Amount"></input><br>
<button onclick="createTransaction();">Send Tx</button>
</div>
<div><button onclick="tests();">Tests</button></div>
<div id="debug" style="border: 1px solid block"></div>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

@ -0,0 +1,34 @@
/* Space out content a bit */
body {
padding-top: 20px;
padding-bottom: 20px;
}
/* Everything but the jumbotron gets side spacing for mobile first
* views */
.header,
.marketing,
.footer {
padding-right: 15px;
padding-left: 15px;
}
/* Custom page header */
.header {
border-bottom: 1px solid #e5e5e5;
}
/* Make the masthead heading the same height as the navigation */
.header h3 {
padding-bottom: 19px;
margin-top: 0;
margin-bottom: 0;
line-height: 40px;
}
.jumbotron {
text-align: center;
border-bottom: 1px solid #e5e5e5;
margin: 0 auto;
width: 300px;
}

@ -0,0 +1,70 @@
<html>
<head>
<title>jeffcoin</title>
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="bootstrap-theme.min.css">
<link rel="stylesheet" href="samplecoin.css">
<meta name="viewport" content="minimum-scale=1; maximum-scale=1; initial-scale=1;">
<script type="text/javascript">
var jefcoinAddr = "3dff537f51350239abc95c76a5864aa605259e7d"
var mAddr = ""
function createTransaction() {
var addr = document.querySelector("#addr").value;
var amount = document.querySelector("#amount").value;
var data = (("0x"+addr).pad(32) + amount.pad(32)).unbin()
eth.transact(mAddr, jefcoinAddr, 0, "10000000", "250", data, function(tx) {
debug("received tx hash:", tx)
})
}
function init() {
eth.set({width: 500})
eth.getKey(function(keyPair) {
mAddr = keyPair.privateKey;
eth.getStorageAt(jefcoinAddr, keyPair.address, function(storage) {
document.querySelector("#current-amount").innerHTML = storage;
});
eth.watch(jefcoinAddr, function(stateObject) {
eth.getStorageAt(jefcoinAddr, keyPair.address, function(storage) {
document.querySelector("#current-amount").innerHTML = storage;
});
});
});
}
</script>
</head>
<body onload="init();">
<div class="container">
<div class="header">
<h3 class="text-muted">JeffCoin</h3>
</div>
<div class="jumbotron ">
<img src="icon.png">
<div>Amount: <strong id="current-amount"></strong></div>
<div id="transactions">
<div class="form-group">
<input id="addr" class="form-control" type="text" placeholder="Receiver address"></input><br>
<input id="amount" class="form-control" type="text" placeholder="Amount"></input><br>
</div>
<button class="btn btn-default" onclick="createTransaction();">Send Tx</button>
</div>
</div>
</div>
<div id="debug" style="border: 1px solid black; min-height: 30px;"></div>
</body>
</html>

@ -1,55 +0,0 @@
<html>
<head>
<title>jeffcoin</title>
<script type="text/javascript">
var jefcoinAddr = "3dff537f51350239abc95c76a5864aa605259e7d"
function createTransaction() {
var addr = document.querySelector("#addr").value;
var amount = document.querySelector("#amount").value;
var data = "0x" + addr + "\n" + amount
eth.createTx(jefcoinAddr, 0, "10000000", "250", data, function(tx) {
debug("received tx hash:", tx)
})
}
function init() {
eth.getKey(function(key) {
eth.getStorage(jefcoinAddr, key, function(storage) {
document.querySelector("#currentAmount").innerHTML = "Amount: " + storage;
});
eth.on("block:new", function() {
eth.getStorage(jefcoinAddr, key, function(storage) {
document.querySelector("#currentAmount").innerHTML = "Amount: " + storage;
});
});
});
}
</script>
<style type="text/css">
input[type="text"] {
width: 300px;
}
</style>
</head>
<body onload="init();">
<h1>Jeff Coin</h1>
<img src="icon.png">
<div id="currentAmount"></div>
<div id="transactions">
<input id="addr" type="text" placeholder="Receiver address"></input><br>
<input id="amount" type="text" placeholder="Amount"></input><br>
<button onclick="createTransaction();">Send Tx</button>
</div>
<div id="debug" style="border: 1px solid block"></div>
</body>
</html>

@ -2,13 +2,11 @@ package ethui
import (
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml"
"math/big"
"strings"
)
type AppContainer interface {
@ -24,7 +22,7 @@ type AppContainer interface {
}
type ExtApplication struct {
*QEthereum
*utils.PEthereum
blockChan chan ethutil.React
changeChan chan ethutil.React
@ -37,7 +35,7 @@ type ExtApplication struct {
func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
app := &ExtApplication{
NewQEthereum(lib.eth),
utils.NewPEthereum(lib.eth),
make(chan ethutil.React, 1),
make(chan ethutil.React, 1),
make(chan bool),
@ -127,93 +125,3 @@ func (app *ExtApplication) Watch(addr, storageAddr string) {
app.registeredEvents = append(app.registeredEvents, event)
}
type QEthereum struct {
stateManager *ethchain.StateManager
blockChain *ethchain.BlockChain
txPool *ethchain.TxPool
}
func NewQEthereum(eth *eth.Ethereum) *QEthereum {
return &QEthereum{
eth.StateManager(),
eth.BlockChain(),
eth.TxPool(),
}
}
func (lib *QEthereum) GetBlock(hexHash string) *QBlock {
hash := ethutil.FromHex(hexHash)
block := lib.blockChain.GetBlock(hash)
return &QBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
}
func (lib *QEthereum) GetKey() string {
return ethutil.Hex(ethutil.Config.Db.GetKeys()[0].Address())
}
func (lib *QEthereum) GetStateObject(address string) *QStateObject {
stateObject := lib.stateManager.ProcState().GetContract(ethutil.FromHex(address))
if stateObject != nil {
return NewQStateObject(stateObject)
}
// See GetStorage for explanation on "nil"
return NewQStateObject(nil)
}
func (lib *QEthereum) Watch(addr, storageAddr string) {
// lib.stateManager.Watch(ethutil.FromHex(addr), ethutil.FromHex(storageAddr))
}
func (lib *QEthereum) CreateTx(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
return lib.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr)
}
func (lib *QEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
var hash []byte
var contractCreation bool
if len(recipient) == 0 {
contractCreation = true
} else {
hash = ethutil.FromHex(recipient)
}
keyPair := ethutil.Config.Db.GetKeys()[0]
value := ethutil.Big(valueStr)
gas := ethutil.Big(gasStr)
gasPrice := ethutil.Big(gasPriceStr)
var tx *ethchain.Transaction
// Compile and assemble the given data
if contractCreation {
// Compile script
mainScript, initScript, err := utils.CompileScript(dataStr)
if err != nil {
return "", err
}
tx = ethchain.NewContractCreationTx(value, gas, gasPrice, mainScript, initScript)
} else {
lines := strings.Split(dataStr, "\n")
var data []byte
for _, line := range lines {
data = append(data, ethutil.BigToBytes(ethutil.Big(line), 256)...)
}
tx = ethchain.NewTransactionMessage(hash, value, gas, gasPrice, data)
}
acc := lib.stateManager.GetAddrState(keyPair.Address())
tx.Nonce = acc.Nonce
tx.Sign(keyPair.PrivateKey)
lib.txPool.QueueTransaction(tx)
if contractCreation {
ethutil.Config.Log.Infof("Contract addr %x", tx.Hash()[12:])
} else {
ethutil.Config.Log.Infof("Tx hash %x", tx.Hash())
}
return ethutil.Hex(tx.Hash()), nil
}

@ -7,6 +7,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml"
"math/big"
"strings"
@ -56,9 +57,9 @@ func (ui *Gui) Start(assetPath string) {
// Register ethereum functions
qml.RegisterTypes("Ethereum", 1, 0, []qml.TypeSpec{{
Init: func(p *QBlock, obj qml.Object) { p.Number = 0; p.Hash = "" },
Init: func(p *utils.PBlock, obj qml.Object) { p.Number = 0; p.Hash = "" },
}, {
Init: func(p *QTx, obj qml.Object) { p.Value = ""; p.Hash = ""; p.Address = "" },
Init: func(p *utils.PTx, obj qml.Object) { p.Value = ""; p.Hash = ""; p.Address = "" },
}})
ethutil.Config.SetClientString(fmt.Sprintf("/Ethereal v%s", "0.2"))
@ -129,13 +130,13 @@ func (ui *Gui) readPreviousTransactions() {
for it.Next() {
tx := ethchain.NewTransactionFromBytes(it.Value())
ui.win.Root().Call("addTx", NewQTx(tx))
ui.win.Root().Call("addTx", utils.NewPTx(tx))
}
it.Release()
}
func (ui *Gui) ProcessBlock(block *ethchain.Block) {
ui.win.Root().Call("addBlock", NewQBlock(block))
ui.win.Root().Call("addBlock", utils.NewPBlock(block))
}
// Simple go routine function that updates the list of peers in the GUI
@ -156,13 +157,13 @@ func (ui *Gui) update() {
if txMsg.Type == ethchain.TxPre {
if bytes.Compare(tx.Sender(), ui.addr) == 0 && addrState.Nonce <= tx.Nonce {
ui.win.Root().Call("addTx", NewQTx(tx))
ui.win.Root().Call("addTx", utils.NewPTx(tx))
ui.txDb.Put(tx.Hash(), tx.RlpEncode())
addrState.Nonce += 1
unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
} else if bytes.Compare(tx.Recipient, ui.addr) == 0 {
ui.win.Root().Call("addTx", NewQTx(tx))
ui.win.Root().Call("addTx", utils.NewPTx(tx))
ui.txDb.Put(tx.Hash(), tx.RlpEncode())
unconfirmedFunds.Add(unconfirmedFunds, tx.Value)

@ -4,6 +4,7 @@ import (
"errors"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml"
"math/big"
"path/filepath"
@ -56,12 +57,12 @@ func (app *HtmlApplication) Window() *qml.Window {
}
func (app *HtmlApplication) NewBlock(block *ethchain.Block) {
b := &QBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
b := &utils.PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
app.webView.Call("onNewBlockCb", b)
}
func (app *HtmlApplication) ObjectChanged(stateObject *ethchain.StateObject) {
app.webView.Call("onObjectChangeCb", NewQStateObject(stateObject))
app.webView.Call("onObjectChangeCb", utils.NewPStateObject(stateObject))
}
func (app *HtmlApplication) StorageChanged(stateObject *ethchain.StateObject, addr []byte, value *big.Int) {

@ -47,14 +47,14 @@ func (lib *EthLib) GetKey() string {
return ethutil.Hex(ethutil.Config.Db.GetKeys()[0].Address())
}
func (lib *EthLib) GetStateObject(address string) *QStateObject {
func (lib *EthLib) GetStateObject(address string) *utils.PStateObject {
stateObject := lib.stateManager.ProcState().GetContract(ethutil.FromHex(address))
if stateObject != nil {
return NewQStateObject(stateObject)
return utils.NewPStateObject(stateObject)
}
// See GetStorage for explanation on "nil"
return NewQStateObject(nil)
return utils.NewPStateObject(nil)
}
func (lib *EthLib) Watch(addr, storageAddr string) {
@ -115,7 +115,7 @@ func (lib *EthLib) Transact(recipient, valueStr, gasStr, gasPriceStr, dataStr st
return ethutil.Hex(tx.Hash()), nil
}
func (lib *EthLib) GetBlock(hexHash string) *QBlock {
func (lib *EthLib) GetBlock(hexHash string) *utils.PBlock {
hash, err := hex.DecodeString(hexHash)
if err != nil {
return nil
@ -123,5 +123,5 @@ func (lib *EthLib) GetBlock(hexHash string) *QBlock {
block := lib.blockChain.GetBlock(hash)
return &QBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
return &utils.PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
}

@ -0,0 +1,110 @@
package utils
import (
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
)
type PEthereum struct {
stateManager *ethchain.StateManager
blockChain *ethchain.BlockChain
txPool *ethchain.TxPool
}
func NewPEthereum(eth *eth.Ethereum) *PEthereum {
return &PEthereum{
eth.StateManager(),
eth.BlockChain(),
eth.TxPool(),
}
}
func (lib *PEthereum) GetBlock(hexHash string) *PBlock {
hash := ethutil.FromHex(hexHash)
block := lib.blockChain.GetBlock(hash)
return &PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
}
func (lib *PEthereum) GetKey() *PKey {
keyPair, err := ethchain.NewKeyPairFromSec(ethutil.Config.Db.GetKeys()[0].PrivateKey)
if err != nil {
return nil
}
return NewPKey(keyPair)
}
func (lib *PEthereum) GetStateObject(address string) *PStateObject {
stateObject := lib.stateManager.ProcState().GetContract(ethutil.FromHex(address))
if stateObject != nil {
return NewPStateObject(stateObject)
}
// See GetStorage for explanation on "nil"
return NewPStateObject(nil)
}
func (lib *PEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
return lib.createTx(key, recipient, valueStr, gasStr, gasPriceStr, dataStr, "")
}
func (lib *PEthereum) Create(key, valueStr, gasStr, gasPriceStr, initStr, bodyStr string) (string, error) {
return lib.createTx(key, "", valueStr, gasStr, gasPriceStr, initStr, bodyStr)
}
func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, initStr, scriptStr string) (string, error) {
var hash []byte
var contractCreation bool
if len(recipient) == 0 {
contractCreation = true
} else {
hash = ethutil.FromHex(recipient)
}
keyPair, err := ethchain.NewKeyPairFromSec([]byte(ethutil.FromHex(key)))
if err != nil {
return "", err
}
value := ethutil.Big(valueStr)
gas := ethutil.Big(gasStr)
gasPrice := ethutil.Big(gasPriceStr)
var tx *ethchain.Transaction
// Compile and assemble the given data
if contractCreation {
initScript, err := Compile(initStr)
if err != nil {
return "", err
}
mainScript, err := Compile(scriptStr)
if err != nil {
return "", err
}
tx = ethchain.NewContractCreationTx(value, gas, gasPrice, mainScript, initScript)
} else {
// Just in case it was submitted as a 0x prefixed string
if initStr[0:2] == "0x" {
initStr = initStr[2:len(initStr)]
}
fmt.Println("DATA:", initStr)
tx = ethchain.NewTransactionMessage(hash, value, gas, gasPrice, ethutil.FromHex(initStr))
}
acc := lib.stateManager.GetAddrState(keyPair.Address())
tx.Nonce = acc.Nonce
tx.Sign(keyPair.PrivateKey)
lib.txPool.QueueTransaction(tx)
if contractCreation {
ethutil.Config.Log.Infof("Contract addr %x", tx.Hash()[12:])
} else {
ethutil.Config.Log.Infof("Tx hash %x", tx.Hash())
}
return ethutil.Hex(tx.Hash()), nil
}

@ -1,4 +1,4 @@
package ethui
package utils
import (
"encoding/hex"
@ -7,53 +7,61 @@ import (
)
// Block interface exposed to QML
type QBlock struct {
type PBlock struct {
Number int
Hash string
}
// Creates a new QML Block from a chain block
func NewQBlock(block *ethchain.Block) *QBlock {
func NewPBlock(block *ethchain.Block) *PBlock {
info := block.BlockInfo()
hash := hex.EncodeToString(block.Hash())
return &QBlock{Number: int(info.Number), Hash: hash}
return &PBlock{Number: int(info.Number), Hash: hash}
}
type QTx struct {
type PTx struct {
Value, Hash, Address string
Contract bool
}
func NewQTx(tx *ethchain.Transaction) *QTx {
func NewPTx(tx *ethchain.Transaction) *PTx {
hash := hex.EncodeToString(tx.Hash())
sender := hex.EncodeToString(tx.Recipient)
isContract := len(tx.Data) > 0
return &QTx{Hash: hash, Value: ethutil.CurrencyToString(tx.Value), Address: sender, Contract: isContract}
return &PTx{Hash: hash, Value: ethutil.CurrencyToString(tx.Value), Address: sender, Contract: isContract}
}
type QKey struct {
Address string
type PKey struct {
Address string
PrivateKey string
PublicKey string
}
type QKeyRing struct {
func NewPKey(key *ethchain.KeyPair) *PKey {
return &PKey{ethutil.Hex(key.Address()), ethutil.Hex(key.PrivateKey), ethutil.Hex(key.PublicKey)}
}
/*
type PKeyRing struct {
Keys []interface{}
}
func NewQKeyRing(keys []interface{}) *QKeyRing {
return &QKeyRing{Keys: keys}
func NewPKeyRing(keys []interface{}) *PKeyRing {
return &PKeyRing{Keys: keys}
}
*/
type QStateObject struct {
type PStateObject struct {
object *ethchain.StateObject
}
func NewQStateObject(object *ethchain.StateObject) *QStateObject {
return &QStateObject{object: object}
func NewPStateObject(object *ethchain.StateObject) *PStateObject {
return &PStateObject{object: object}
}
func (c *QStateObject) GetStorage(address string) string {
func (c *PStateObject) GetStorage(address string) string {
// Because somehow, even if you return nil to QML it
// still has some magical object so we can't rely on
// undefined or null at the QML side
@ -66,7 +74,7 @@ func (c *QStateObject) GetStorage(address string) string {
return ""
}
func (c *QStateObject) Value() string {
func (c *PStateObject) Value() string {
if c.object != nil {
return c.object.Amount.String()
}
@ -74,7 +82,7 @@ func (c *QStateObject) Value() string {
return ""
}
func (c *QStateObject) Address() string {
func (c *PStateObject) Address() string {
if c.object != nil {
return ethutil.Hex(c.object.Address())
}
Loading…
Cancel
Save