@@ -1053,8 +1053,8 @@ export class EventStorer {
10531053 const [ from , to , value ] = logArgs
10541054 const _from = await findOrCreateEntity ( em , Entities . EvmAddress , { hex : from } )
10551055 const _to = await findOrCreateEntity ( em , Entities . EvmAddress , { hex : to } )
1056- await this . increaseTokenBalance ( em , evmLog . address , _to , value )
1057- await this . increaseTokenBalance ( em , evmLog . address , _from , - value )
1056+ await this . changeTokenBalance ( em , evmLog . address , _to , value )
1057+ await this . changeTokenBalance ( em , evmLog . address , _from , - value )
10581058 return em . create ( Entities . ERC20Transfer , { evmLog, from : _from , to : _to , value } )
10591059 }
10601060
@@ -1519,13 +1519,14 @@ export class EventStorer {
15191519 } , { persist : false } )
15201520 }
15211521
1522- private async increaseTokenBalance (
1522+ private async changeTokenBalance (
15231523 em : EntityManager ,
15241524 token : Entities . EvmAddress ,
15251525 holder : Entities . EvmAddress ,
1526- amount : bigint
1526+ diff : bigint
15271527 ) : Promise < void > {
1528- const balance = await findOrCreateEntity ( em , Entities . TokenBalance , { token, holder } , { } , { token, holder, amount } )
1529- balance . amount = amount
1528+ const balance = await findOrCreateEntity ( em , Entities . TokenBalance ,
1529+ { token, holder } , { } , { token, holder, amount : BigInt ( 0 ) } )
1530+ balance . amount += diff
15301531 }
15311532}
0 commit comments