Part of [Generate watchers for sushiswap subgraphs deployed in graph-node](https://www.notion.so/Generate-watchers-for-sushiswap-subgraphs-deployed-in-graph-node-b3f2e475373d4ab1887d9f8720bd5ae6) Reviewed-on: cerc-io/sushiswap-watcher-ts#2 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
22 lines
761 B
TypeScript
22 lines
761 B
TypeScript
//
|
|
// Copyright 2022 Vulcanize, Inc.
|
|
//
|
|
|
|
import { EventSubscriber, EntitySubscriberInterface, InsertEvent, UpdateEvent } from 'typeorm';
|
|
|
|
import { afterEntityInsertOrUpdate } from '@cerc-io/util';
|
|
|
|
import { FrothyEntity } from './FrothyEntity';
|
|
import { ENTITY_TO_LATEST_ENTITY_MAP, SUBGRAPH_ENTITIES } from '../database';
|
|
|
|
@EventSubscriber()
|
|
export class EntitySubscriber implements EntitySubscriberInterface {
|
|
async afterInsert (event: InsertEvent<any>): Promise<void> {
|
|
await afterEntityInsertOrUpdate(FrothyEntity, SUBGRAPH_ENTITIES, event, ENTITY_TO_LATEST_ENTITY_MAP);
|
|
}
|
|
|
|
async afterUpdate (event: UpdateEvent<any>): Promise<void> {
|
|
await afterEntityInsertOrUpdate(FrothyEntity, SUBGRAPH_ENTITIES, event, ENTITY_TO_LATEST_ENTITY_MAP);
|
|
}
|
|
}
|