aboutsummaryrefslogtreecommitdiffstats
path: root/mist/assets/qml/test_app.qml
blob: c69587839ebe1738f69146d5507510917fe3b163 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import QtQuick 2.0
import QtQuick.Controls 1.0;
import QtQuick.Layouts 1.0;
import Ethereum 1.0

QmlApp {
    minimumWidth: 350
    maximumWidth: 350
    maximumHeight: 80
    minimumHeight: 80

    title: "Generic Coin"

    property string contractAddr: "f299f6c74515620e4c4cd8fe3d205b5c4f2e25c8"
    property string addr: "2ef47100e0787b915105fd5e3f4ff6752079d5cb"

    Component.onCompleted: {
        eth.watch(contractAddr, addr)
        eth.watch(addr, contractAddr)
        setAmount()
    }

    function onStorageChangeCb(storageObject) {
        setAmount()
    }

    function setAmount(){
        var state = eth.getStateObject(contractAddr)
        var storage = state.getStorage(addr)
        amountLabel.text = storage
    }
    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
        }
    }

}