2014-02-21 18:29:59 +02:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Controls 1.0;
|
|
|
|
import QtQuick.Layouts 1.0;
|
2014-02-23 00:19:38 +02:00
|
|
|
import Ethereum 1.0
|
2014-02-21 18:29:59 +02:00
|
|
|
|
2014-06-23 17:25:57 +03:00
|
|
|
QmlApp {
|
|
|
|
minimumWidth: 350
|
|
|
|
maximumWidth: 350
|
|
|
|
maximumHeight: 80
|
|
|
|
minimumHeight: 80
|
2014-02-21 18:29:59 +02:00
|
|
|
|
2014-06-23 17:25:57 +03:00
|
|
|
title: "Generic Coin"
|
2014-02-21 18:29:59 +02:00
|
|
|
|
2014-06-23 17:25:57 +03:00
|
|
|
property string contractAddr: "f299f6c74515620e4c4cd8fe3d205b5c4f2e25c8"
|
|
|
|
property string addr: "2ef47100e0787b915105fd5e3f4ff6752079d5cb"
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
eth.watch(contractAddr, addr)
|
|
|
|
eth.watch(addr, contractAddr)
|
|
|
|
setAmount()
|
|
|
|
}
|
|
|
|
|
|
|
|
function onStorageChangeCb(storageObject) {
|
|
|
|
setAmount()
|
2014-02-21 18:29:59 +02:00
|
|
|
}
|
2014-06-23 17:25:57 +03:00
|
|
|
|
|
|
|
function setAmount(){
|
|
|
|
var state = eth.getStateObject(contractAddr)
|
|
|
|
var storage = state.getStorage(addr)
|
|
|
|
amountLabel.text = storage
|
2014-02-21 18:29:59 +02:00
|
|
|
}
|
2014-06-23 17:25:57 +03:00
|
|
|
Column {
|
|
|
|
spacing: 5
|
|
|
|
Row {
|
|
|
|
spacing: 20
|
|
|
|
Label {
|
|
|
|
id: genLabel
|
|
|
|
text: "Generic coin balance:"
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: amountLabel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Row {
|
|
|
|
spacing: 20
|
|
|
|
TextField {
|
|
|
|
id: address
|
|
|
|
placeholderText: "Address"
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: amount
|
|
|
|
placeholderText: "Amount"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: "Send coins"
|
|
|
|
onClicked: {
|
|
|
|
var privKey = eth.getKey().privateKey
|
|
|
|
if(privKey){
|
|
|
|
var result = eth.transact(privKey, contractAddr, 0,"100000","250", "0x" + address.text + "\n" + amount.text)
|
|
|
|
resultTx.text = result.hash
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: resultTx
|
2014-02-21 18:29:59 +02:00
|
|
|
}
|
|
|
|
}
|
2014-06-23 17:25:57 +03:00
|
|
|
|
2014-02-21 18:29:59 +02:00
|
|
|
}
|