Skip to content

Commit bae916e

Browse files
committed
fix: update missing entities in allocation resize
Signed-off-by: Tomás Migone <[email protected]>
1 parent 879da8c commit bae916e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/mappings/subgraphService.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,22 @@ export function handleAllocationResized(event: AllocationResized): void {
206206
let allocation = Allocation.load(allocationID)!
207207
allocation.allocatedTokens = event.params.newTokens
208208
allocation.save()
209+
210+
// update data service
211+
let dataService = createOrLoadDataService(event.address)
212+
dataService.totalTokensAllocated = dataService.totalTokensAllocated.plus(diffTokens)
213+
dataService.save()
214+
215+
// update subgraph deployment
216+
let subgraphDeploymentID = allocation.subgraphDeployment
217+
let deployment = createOrLoadSubgraphDeployment(subgraphDeploymentID, event.block.timestamp)
218+
deployment.stakedTokens = deployment.stakedTokens.plus(diffTokens)
219+
deployment.save()
220+
221+
// update graph network
222+
let graphNetwork = createOrLoadGraphNetwork(event.block.number, event.address)
223+
graphNetwork.totalTokensAllocated = graphNetwork.totalTokensAllocated.plus(diffTokens)
224+
graphNetwork.save()
209225
}
210226

211227
export function handleIndexingRewardsCollected(event: IndexingRewardsCollected): void {

0 commit comments

Comments
 (0)