Skip to content

Commit 79ee6e5

Browse files
committed
fix: fix-negative-number-of-request-crash
1 parent 122650a commit 79ee6e5

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gtcr-subgraph",
3-
"version": "1.1.8",
3+
"version": "1.2.1",
44
"description": "Subgraph for Generalized TCR contracts",
55
"scripts": {
66
"clean": "graph clean",

src/LightGeneralizedTCRMapping.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
Ruling,
4141
ConnectedTCRSet as ConnectedTCRSetEvent,
4242
} from '../generated/templates/LightGeneralizedTCR/LightGeneralizedTCR';
43-
import { ZERO_ADDRESS, extractPath } from './utils';
43+
import { ZERO, ZERO_ADDRESS, extractPath } from './utils';
4444

4545
// Items on a TCR can be in 1 of 4 states:
4646
// - (0) Absent: The item is not registered on the TCR and there are no pending requests.
@@ -658,6 +658,15 @@ export function handleStatusUpdated(event: ItemStatusChange): void {
658658

659659
item.latestRequestResolutionTime = event.block.timestamp;
660660

661+
if(item.numberOfRequests.equals(ZERO)){
662+
log.error(
663+
`Encountered 0 as numberOfRequest for Item : {}`,
664+
[graphItemID],
665+
);
666+
item.save();
667+
return;
668+
}
669+
661670
let requestIndex = item.numberOfRequests.minus(BigInt.fromI32(1));
662671
let requestInfo = tcr.try_getRequestInfo(event.params._itemID, requestIndex);
663672
if (requestInfo.reverted) {

subgraph.template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
specVersion: 1.0.0
2-
description: Generalized TCR
2+
description: Generalized TCR v1.2.1
33
features:
44
- fullTextSearch
55
- ipfsOnEthereumContracts

0 commit comments

Comments
 (0)