diff --git a/src/LidoDAO.ts b/src/LidoDAO.ts index 9ab399d..76dca0f 100644 --- a/src/LidoDAO.ts +++ b/src/LidoDAO.ts @@ -1,4 +1,4 @@ -import { Address, Bytes } from '@graphprotocol/graph-ts' +import { Address } from '@graphprotocol/graph-ts' import { SetApp as SetAppEvent } from '../generated/LidoDAO/LidoDAO' import { AppRepo } from '../generated/LidoDAO/AppRepo' import { AppVersion } from '../generated/schema' @@ -6,6 +6,7 @@ import { KERNEL_APP_BASES_NAMESPACE, APP_REPOS, ZERO_ADDRESS, + network, } from './constants' export function handleSetApp(event: SetAppEvent): void { @@ -22,12 +23,24 @@ export function handleSetApp(event: SetAppEvent): void { // updating only in case of a new contract address if (entity.impl != event.params.app) { const repo = AppRepo.bind(Address.fromString(repoAddr)) - const latest = repo.getLatestForContractAddress(event.params.app) - const semVer = latest.getSemanticVersion() - entity.major = semVer[0] - entity.minor = semVer[1] - entity.patch = semVer[2] + const triedLatest = repo.try_getLatestForContractAddress(event.params.app) + if (triedLatest.reverted) { + if (network === 'mainnet') { + throw new Error('indexing error - getLatestForContractAddress method is reverted') + } + + entity.major = 0; + entity.minor = 0; + entity.patch = 0; + } else { + const semVer = triedLatest.value.getSemanticVersion() + + entity.major = semVer[0] + entity.minor = semVer[1] + entity.patch = semVer[2] + } + entity.impl = event.params.app entity.block = event.block.number