Skip to content
Snippets Groups Projects
Commit 38d4c753 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Mejorando distiliera1

parent c57e6963
No related branches found
No related tags found
No related merge requests found
......@@ -30,12 +30,13 @@ function init()
if ( table[i] == notation.potency )
notation.name = table[i+1]
if ( undefined == notation.name )
notation = { 'potency': 15, 'name': 'finney' };
notation.num = BigNumber( 10 ).pow( notation.potency );
notation = { 'potency': 15, 'name': 'finney' };
notation.num = BigNumber( 10 ).pow( notation.potency );
bfa = new Libbfa();
web3 = bfa.newweb3();
Distillery = bfa.contract( web3, 'Distillery' );
requestBalances();
requestDistBalance()
.then( requestBalances )
}
function palletSort(a,b)
......@@ -58,13 +59,17 @@ function palletSort(a,b)
return 0;
}
async function requestDistBalance()
{
return web3.eth.getBalance(Distillery.contractaddress)
.then( (bal) => { return Distillery.contractbalance = new BigNumber( bal ) } )
}
async function requestBalances()
{
var distbal = await web3.eth.getBalance(Distillery.contractaddress);
var count = await Distillery.methods.numberOfBeneficiaries().call();
var pallet = new Array;
var i;
Distillery.contractbalance = new BigNumber( distbal );
// Fetch addresses from the list in the contract.
for ( i=0; i<count; i++ )
{
......@@ -126,7 +131,21 @@ function editAccount( entry, pallet )
+ rcpt.gasUsed
+ " gas."
);
requestBalances();
var beforeBal = Distillery.contractbalance;
requestDistBalance()
.then(
function()
{
console.log(
"Distributed "
+ beforeBal.minus( Distillery.contractbalance ).div( notation.num ).toFixed()
+ " "
+ notation.name
+ "."
);
requestBalances();
}
)
}
}
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment