Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/hosted-fungible/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ <h2>Chain history for <code id="chain-id" class="hex">requesting a new microchai
parent.insertBefore(entry, parent.firstChild);
}

async function updateBalance(application) {
const response = JSON.parse(await application.query(gql(`query { tickerSymbol, accounts { entries { key value } } }`)));
async function updateBalance(application, owner) {
const response = JSON.parse(await application.query(gql(`query { tickerSymbol, accounts { entry(key: "${owner}") { value } } }`)));
console.debug('application response:', response);
document.querySelector('#ticker-symbol').textContent = response.data.tickerSymbol;
document.querySelector('#balance').textContent = (+(response?.data?.accounts?.entries?.[0]?.value || 0)).toFixed(2);
document.querySelector('#balance').textContent = (+( response.data.accounts.entry?.value || 0)).toFixed(2);
}

async function transfer(application, donor, amount, recipient) {
Expand Down Expand Up @@ -232,13 +232,13 @@ <h2>Chain history for <code id="chain-id" class="hex">requesting a new microchai

const application = await client.frontend().application(FUNGIBLE_APP_ID);

await updateBalance(application);
await updateBalance(application, owner);

client.onNotification(notification => {
let newBlock = notification.reason.NewBlock;
if (!newBlock) return;
prependEntry(document.querySelector('#logs'), newBlock);
updateBalance(application);
updateBalance(application, owner);
});

submitButton.disabled = false;
Expand Down