Skip to content

Commit 05ece1a

Browse files
committed
cleanup
1 parent 8f83508 commit 05ece1a

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

amisforum/live/conference/app.js

+28-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,17 @@ function refundTicket(buyerAddress, ticketPrice) {
185185
}
186186
});
187187
}
188-
188+
function getEthBalance() {
189+
contractInstance.getEthBalanceOf(web3.eth.accounts[0], ((error, result) => {
190+
if(!error) {
191+
balance = result;
192+
$('#balance').text("BALANCE: " + web3.fromWei(result, 'ether') + " ETH");
193+
$('#user_balance').text("AVAILABLE BALANCE: " + web3.fromWei(result, 'ether') + " ETH");
194+
} else {
195+
console.log("FAILED TO GET ETH BALANCE");
196+
}
197+
}))
198+
}
189199
// createWallet
190200
function createWallet(password) {
191201

@@ -228,6 +238,11 @@ function getBalance(address) {
228238
return web3.fromWei(web3.eth.getBalance(address).toNumber(), 'ether');
229239
}
230240

241+
242+
243+
244+
245+
231246
// switch to hooked3webprovider which allows for external Tx signing
232247
// (rather than signing from a wallet in the Ethereum client)
233248
function switchToHooked3(_keystore) {
@@ -337,6 +352,18 @@ window.onload = function() {
337352
$("#balance").html(getBalance(address));
338353
});
339354

355+
function getEthBalance() {
356+
contractInstance.getEthBalanceOf(web3.eth.accounts[0], ((error, result) => {
357+
if(!error) {
358+
balance = result;
359+
$('#balance').text("BALANCE: " + web3.fromWei(result, 'ether') + " ETH");
360+
$('#user_balance').text("AVAILABLE BALANCE: " + web3.fromWei(result, 'ether') + " ETH");
361+
} else {
362+
console.log("FAILED TO GET ETH BALANCE");
363+
}
364+
}))
365+
}
366+
340367
// Set value of wallet to accounts[1]
341368
$("#buyerAddress").val(accounts);
342369
$("#refBuyerAddress").val(accounts);

amisforum/live/conference/index.html

+8
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ <h2>Refund a Ticket</h2>
6262

6363
<hr/>
6464

65+
<div class="section">
66+
<h2>Check my Metamask ETH balance</h2>
67+
<button id="checkBalance">Check my ETH Balance</button>
68+
<span id="checkBalanceResult"></span>
69+
</div>
70+
71+
<hr/>
72+
6573
<div class="section">
6674
<h2>Create a Wallet</h2>
6775
Password: <input type="text" id="password" />

0 commit comments

Comments
 (0)