-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMPToken.js
66 lines (55 loc) · 1.85 KB
/
MPToken.js
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
/**
* StromDAO Business Object: MPToken
* =========================================
* Meter Point Token handling for StromDAO Energy Blockchain.
*
* In General a MPToken consists of two ERC-20 Tokens: Time and Power
*
* @author Thorsten Zoerner thorsten.zoerner@stromdao.de
* */
this.mptoken = function(obj_or_address) {
if(typeof obj_or_address == "undefined") obj_or_address=parent.options.contracts["StromDAO-BO.sol:MPToken"];
var p1 = new Promise(function(resolve, reject) {
var instance=parent._objInstance(obj_or_address,'StromDAO-BO.sol:MPToken');
instance.test = {};
/**
* Stores a reading to this contract instance. Requires sender to be approved Meter-Point
* @see approveMP()
*/
instance.issue=function() {
//_reading=Math.round(_reading);
var p2 = new Promise(function(resolve2, reject2) {
instance.obj.issue().then(function(o) {
parent._waitForTransactionKeepRef(o,resolve2);
});
});
return p2;
};
instance.power_token=function() {
var p2 = new Promise(function(resolve2, reject2) {
instance.obj.power_token().then(function(o) {
resolve2(o[0]);
});
});
return p2;
};
instance.time_token=function() {
var p2 = new Promise(function(resolve2, reject2) {
instance.obj.time_token().then(function(o) {
resolve2(o[0]);
});
});
return p2;
};
instance.meterpoint=function() {
var p2 = new Promise(function(resolve2, reject2) {
instance.obj.meterpoint().then(function(o) {
resolve2(o[0]);
});
});
return p2;
};
resolve(instance);
});
return p1;
};