-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Simple MeterPointReading (trust less for IOT Devices)
Conceptual Change to include default contracts in RoleLookup Addpoted Test Cases
- Loading branch information
Showing
50 changed files
with
189 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,58 @@ | ||
this.deployment=function(options) { | ||
var contract_type=[]; | ||
contract_type["StromDAO-BO.sol_DSO"]="0x3D8bB3f14e332ae56bf97E2BddB24a3E1c87bcfb"; | ||
contract_type["StromDAO-BO.sol_MPO"]="0xa037ce97716720C27D67E65Bfcb61b5D315410be"; | ||
contract_type["StromDAO-BO.sol_Provider"]="0x23b0209Bc95dc71f8fc29e526C438C8F4332E4e6"; | ||
|
||
contract_type["StromDAO-BO.sol:DSO"]="0x3D8bB3f14e332ae56bf97E2BddB24a3E1c87bcfb"; | ||
contract_type["StromDAO-BO.sol:MPO"]="0xa037ce97716720C27D67E65Bfcb61b5D315410be"; | ||
contract_type["StromDAO-BO.sol:Provider"]="0x23b0209Bc95dc71f8fc29e526C438C8F4332E4e6"; | ||
|
||
var roles=[]; | ||
roles[0]=0; | ||
roles[1]=1; | ||
roles[2]=2; | ||
roles[3]=3; | ||
options.contracts=contract_type; | ||
|
||
options.rolelookup="0xEC899C1B2CcAEcb3EFA6733CA249aBa58228e883"; | ||
options.roles=roles; | ||
|
||
if(typeof options.rpc == "undefined") options.rpc='http://app.stromdao.de:8081/rpc'; | ||
return options; | ||
}; | ||
this.loadDefaults=function(options) { | ||
if(typeof parent.waitForDefaults == "undefined") { | ||
parent.waitForDefaults = true; | ||
options.rolelookup="0x7B4B8A73f08cc85De6e183deC814077347e26dAF"; | ||
var contract_type=[]; | ||
|
||
if(typeof parent.storage.getItemSync(options.rolelookup+"_1") == "undefined") { | ||
/* | ||
parent.roleLookup(options.rolelookup).then( function(roles) { | ||
roles.defaults(1).then( | ||
function (r1) { | ||
parent.storage.setItemSync(options.rolelookup+"_1",r1); | ||
contract_type["StromDAO-BO.sol_MPO"] = r1; | ||
return roles.defaults(2); | ||
} | ||
).then( | ||
function (r2) { | ||
parent.storage.setItemSync(options.rolelookup+"_2",r2); | ||
contract_type["StromDAO-BO.sol_DSO"] = r2; | ||
return roles.defaults(3); | ||
} | ||
).then( | ||
function (r3) { | ||
parent.storage.setItemSync(options.rolelookup+"_3",r3); | ||
contract_type["StromDAO-BO.sol_Provider"] = r3; | ||
parent.storage.setItemSync(options.rolelookup,contract_type); | ||
} | ||
) | ||
}); | ||
*/ | ||
parent.storage.setItemSync(options.rolelookup+"_1","0x04f6d471bF3b17A4fCC896406A40FFC89A096474"); | ||
parent.storage.setItemSync(options.rolelookup+"_2","0xa7a1828060f6A83FE30b6717A877FacD049f7aDe"); | ||
parent.storage.setItemSync(options.rolelookup+"_3","0x99efcdFDC28DE946EbA951432ABd31aD42d21feb"); | ||
} else { | ||
contract_type["StromDAO-BO.sol_MPO"]=parent.storage.getItemSync(options.rolelookup+"_1"); | ||
contract_type["StromDAO-BO.sol_DSO"]=parent.storage.getItemSync(options.rolelookup+"_2"); | ||
contract_type["StromDAO-BO.sol_Provider"]=parent.storage.getItemSync(options.rolelookup+"_3"); | ||
|
||
} | ||
contract_type["StromDAO-BO.sol_MPR"]="0x6177CeFF392b920881BE7e4789c4B7C075B7Eb64"; | ||
var roles=[]; | ||
roles[0]=0; | ||
roles[1]=1; | ||
roles[2]=2; | ||
roles[3]=3; | ||
options.contracts=contract_type; | ||
options.roles=roles; | ||
parent.waitForDefaults=false; | ||
|
||
return options; | ||
} else { | ||
return options; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* StromDAO Business Object: MPR | ||
* ========================================= | ||
* Meter Point Operator handling for StromDAO Energy Blockchain. | ||
* | ||
* In general a Meter Point Operating (Contract) handles meter readings and issues Deliverables as soon as a new reading is received. | ||
* | ||
* @author Thorsten Zoerner thorsten.zoerner@stromdao.de | ||
* */ | ||
|
||
|
||
this.mpr = function(obj_or_address) { | ||
if(typeof obj_or_address == "undefined") obj_or_address=parent.options.contracts["StromDAO-BO.sol:MPR"]; | ||
|
||
var p1 = new Promise(function(resolve, reject) { | ||
var instance=parent._objInstance(obj_or_address,'StromDAO-BO.sol:MPR'); | ||
instance.test = {}; | ||
|
||
/** | ||
* Stores a reading to this contract instance. Requires sender to be approved Meter-Point | ||
* @see approveMP() | ||
*/ | ||
instance.storeReading=function(_reading) { | ||
_reading=Math.round(_reading); | ||
var p2 = new Promise(function(resolve2, reject2) { | ||
instance.obj.storeReading(_reading).then(function(o) { | ||
parent._waitForTransactionKeepRef(o,resolve2); | ||
}); | ||
}); | ||
return p2; | ||
}; | ||
|
||
/** | ||
* Allows a test commit to check if it fails. Promise that might be used to validate a Meter-Point is fully connected. | ||
*/ | ||
instance.test.storeReading=function(_reading) { | ||
_reading=Math.round(_reading); | ||
var p2 = new Promise(function(resolve2, reject2) { | ||
instance.obj.estimate.storeReading(_reading).then(function(cost) { | ||
resolve2(cost.toString()); | ||
}).catch(function() { reject2(-1); }); | ||
}); | ||
return p2; | ||
}; | ||
|
||
|
||
/** | ||
* Returns last reading for a Meter-Point | ||
*/ | ||
instance.readings=function(_meterpoint) { | ||
var p2 = new Promise(function(resolve2, reject2) { | ||
instance.obj.readings(_meterpoint).then(function(o) { | ||
resolve2(o); | ||
}); | ||
}); | ||
return p2; | ||
}; | ||
|
||
resolve(instance); | ||
}); | ||
return p1; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.