@@ -159,11 +159,11 @@ <h2>Chain history for <code id="chain-id" class="hex">requesting a new microchai
159
159
parent . insertBefore ( entry , parent . firstChild ) ;
160
160
}
161
161
162
- async function updateBalance ( application ) {
163
- const response = JSON . parse ( await application . query ( gql ( `query { tickerSymbol, accounts { entries { key value } } }` ) ) ) ;
162
+ async function updateBalance ( application , owner ) {
163
+ const response = JSON . parse ( await application . query ( gql ( `query { tickerSymbol, accounts { entry(key: " ${ owner } ") { value } } }` ) ) ) ;
164
164
console . debug ( 'application response:' , response ) ;
165
165
document . querySelector ( '#ticker-symbol' ) . textContent = response . data . tickerSymbol ;
166
- document . querySelector ( '#balance' ) . textContent = ( + ( response ? .data ? .accounts ?. entries ?. [ 0 ] ?. value || 0 ) ) . toFixed ( 2 ) ;
166
+ document . querySelector ( '#balance' ) . textContent = ( + ( response . data . accounts . entry ?. value || 0 ) ) . toFixed ( 2 ) ;
167
167
}
168
168
169
169
async function transfer ( application , donor , amount , recipient ) {
@@ -232,13 +232,13 @@ <h2>Chain history for <code id="chain-id" class="hex">requesting a new microchai
232
232
233
233
const application = await client . frontend ( ) . application ( FUNGIBLE_APP_ID ) ;
234
234
235
- await updateBalance ( application ) ;
235
+ await updateBalance ( application , owner ) ;
236
236
237
237
client . onNotification ( notification => {
238
238
let newBlock = notification . reason . NewBlock ;
239
239
if ( ! newBlock ) return ;
240
240
prependEntry ( document . querySelector ( '#logs' ) , newBlock ) ;
241
- updateBalance ( application ) ;
241
+ updateBalance ( application , owner ) ;
242
242
} ) ;
243
243
244
244
submitButton . disabled = false ;
0 commit comments