From 15406fc73162112417f2f567291d804607c5af9b Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Wed, 13 Dec 2023 00:50:10 -0800 Subject: [PATCH] fix(gql): fix cacheKey construction for gql interactions The same cache key is being set for varying blockheights, causing the read through cache to return incorrect interactions when the blockHeight is changed in a new request before the cache has expired. --- src/api/graphql.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/graphql.ts b/src/api/graphql.ts index c9b3172..052f9c3 100644 --- a/src/api/graphql.ts +++ b/src/api/graphql.ts @@ -25,7 +25,6 @@ import { LexicographicalInteractionsSorter, TagsParser, } from 'warp-contracts'; -import logger from '../logger'; import { ReadThroughPromiseCache } from '@ardrive/ardrive-promise-cache'; import winston from 'winston'; @@ -120,7 +119,7 @@ class ContractInteractionsCacheKey { toString(): string { return `${this.contractTxId}-${ - this.blockHeight ? `this.blockHeight` : 'null' + this.blockHeight ? this.blockHeight : 'null' }${this.address ? `-${this.address}` : ''}`; } @@ -176,6 +175,7 @@ export async function readThroughToWalletInteractionsForContract( contractTxId, address, blockHeight: blockHeightFilter, + logger, } = cacheKey; logger?.debug('Reading through to wallet interactions for contract...', { contractTxId, @@ -270,7 +270,7 @@ export async function readThroughToWalletInteractionsForContract( const contractTag = parser.getContractTag(i.node); if (!inputTag || !contractTag) { - logger.debug('Invalid tags for interaction via GQL, ignoring...', { + logger?.debug('Invalid tags for interaction via GQL, ignoring...', { contractTxId, interactionId: i.node.id, inputTag,