From a76f8c188e09771f5c4d121043fc6f77ee9001be Mon Sep 17 00:00:00 2001 From: Juanma Hidalgo Date: Fri, 7 Feb 2025 13:06:58 +0100 Subject: [PATCH] fix: add missing cancelled logic for transferred orders --- indexer/schema.graphql | 1 + indexer/src/modules/nft/index.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/indexer/schema.graphql b/indexer/schema.graphql index 8b331abd2..3660641c8 100644 --- a/indexer/schema.graphql +++ b/indexer/schema.graphql @@ -220,6 +220,7 @@ enum OrderStatus @entity { open sold cancelled + transferred } enum WearableCategory @entity { diff --git a/indexer/src/modules/nft/index.ts b/indexer/src/modules/nft/index.ts index 5a060ac81..2f1bd892c 100644 --- a/indexer/src/modules/nft/index.ts +++ b/indexer/src/modules/nft/index.ts @@ -63,8 +63,14 @@ export function clearNFTOrderProperties(nft: NFT): NFT { } export function cancelActiveOrder(nft: NFT, now: BigInt): boolean { + if (nft.activeOrder == null) { + return false + } let oldOrder = Order.load(nft.activeOrder) - if (oldOrder != null && oldOrder.status == status.OPEN) { + if ( + oldOrder != null && + (oldOrder.status == status.OPEN || oldOrder.status == status.TRANSFERRED) + ) { // Here we are setting old orders as cancelled, because the smart contract allows new orders to be created // and they just overwrite them in place. But the subgraph stores all orders ever // you can also overwrite ones that are expired