From 4f94579473640aad78785792eb21b84dc99cad71 Mon Sep 17 00:00:00 2001 From: juanmardefago Date: Thu, 30 Nov 2023 01:07:30 -0300 Subject: [PATCH] fix: delegation params --- src/mappings/staking.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index 83ad952f..ce70b653 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -49,18 +49,16 @@ import { import { addresses } from '../../config/addresses' export function handleDelegationParametersUpdated(event: DelegationParametersUpdated): void { - let id = event.params.indexer.toHexString() - // Quick fix to avoid creating new Indexer entities if they don't exist yet. - let account = GraphAccount.load(id) - if (account != null) { - let indexer = createOrLoadIndexer(Bytes.fromHexString(id), event.block.timestamp) - indexer.indexingRewardCut = event.params.indexingRewardCut.toI32() - indexer.queryFeeCut = event.params.queryFeeCut.toI32() - indexer.delegatorParameterCooldown = event.params.cooldownBlocks.toI32() - indexer.lastDelegationParameterUpdate = event.block.number.toI32() - indexer = updateAdvancedIndexerMetrics(indexer as Indexer) - indexer.save() - } + let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address) + let indexer = createOrLoadIndexer(event.params.indexer, event.block.timestamp) + indexer.indexingRewardCut = event.params.indexingRewardCut.toI32() + indexer.queryFeeCut = event.params.queryFeeCut.toI32() + indexer.delegatorParameterCooldown = event.params.cooldownBlocks.toI32() + indexer.lastDelegationParameterUpdate = ( + addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber! + ).toI32() + indexer = updateAdvancedIndexerMetrics(indexer as Indexer) + indexer.save() } /**