@@ -386,6 +386,7 @@ export async function handleNativeBalanceDecrement(event: CosmosEvent): Promise<
386386 // {"key":"spender","value":"fetch1wurz7uwmvchhc8x0yztc7220hxs9jxdjdsrqmn"},
387387 // {"key":"amount","value":"100atestfet"}
388388 // ]
389+
389390 let spendEvents = [ ] ;
390391 for ( const [ i , e ] of Object . entries ( event . event . attributes ) ) {
391392 if ( e . key !== "spender" ) {
@@ -397,11 +398,15 @@ export async function handleNativeBalanceDecrement(event: CosmosEvent): Promise<
397398 const coin = parseCoins ( amountStr ) [ 0 ] ;
398399 const amount = BigInt ( 0 ) - BigInt ( coin . amount ) ; // save a negative amount for a "spend" event
399400 spendEvents . push ( { spender : spender , amount : amount , denom : coin . denom } )
400- } ;
401+ }
401402
402403 for ( const [ i , spendEvent ] of Object . entries ( spendEvents ) ) {
403404 await saveNativeBalanceEvent ( `${ messageId ( event ) } -spend-${ i } ` , spendEvent . spender , spendEvent . amount , spendEvent . denom , event ) ;
404405 }
406+
407+ const tx = event . tx . decodedTx ;
408+ const fee = tx . authInfo . fee ;
409+ await saveNativeBalanceEvent ( `${ messageId ( event ) } -fee` , fee . payer , BigInt ( 0 ) - BigInt ( fee . amount [ 0 ] . amount ) , fee . amount [ 0 ] . denom , event ) ;
405410}
406411
407412export async function handleNativeBalanceIncrement ( event : CosmosEvent ) : Promise < void > {
@@ -416,6 +421,7 @@ export async function handleNativeBalanceIncrement(event: CosmosEvent): Promise<
416421 // {"key":"receiver","value":"fetch1wurz7uwmvchhc8x0yztc7220hxs9jxdjdsrqmn"},
417422 // {"key":"amount","value":"100atestfet"}
418423 // ]
424+
419425 let receiveEvents = [ ] ;
420426 for ( const [ i , e ] of Object . entries ( event . event . attributes ) ) {
421427 if ( e . key !== "receiver" ) {
@@ -427,11 +433,15 @@ export async function handleNativeBalanceIncrement(event: CosmosEvent): Promise<
427433 const coin = parseCoins ( amountStr ) [ 0 ] ;
428434 const amount = BigInt ( coin . amount ) ;
429435 receiveEvents . push ( { receiver : receiver , amount : amount , denom : coin . denom } )
430- } ;
436+ }
431437
432438 for ( const [ i , receiveEvent ] of Object . entries ( receiveEvents ) ) {
433439 await saveNativeBalanceEvent ( `${ messageId ( event ) } -receive-${ i } ` , receiveEvent . receiver , receiveEvent . amount , receiveEvent . denom , event ) ;
434440 }
441+
442+ const tx = event . tx . decodedTx ;
443+ const fee = tx . authInfo . fee ;
444+ await saveNativeBalanceEvent ( `${ messageId ( event ) } -fee` , fee . payer , BigInt ( 0 ) - BigInt ( fee . amount [ 0 ] . amount ) , fee . amount [ 0 ] . denom , event ) ;
435445}
436446
437447async function checkBalancesAccount ( address : string , chainId : string ) {
0 commit comments