diff --git a/schema.graphql b/schema.graphql index ba94bad..1ab2c76 100644 --- a/schema.graphql +++ b/schema.graphql @@ -263,6 +263,10 @@ type LRequest @entity { creationTx: Bytes! "The hash of the transaction that solved this request." resolutionTx: Bytes + "The tx hash of the challenge that raised the dispute." + txHashChallenge: Bytes + "The block timestamp of the challenge." + challengeTime: BigInt } type LRound @entity { @@ -305,6 +309,10 @@ type LRound @entity { appealed: Boolean! "When this round was appealed, if it was appealed" appealedAt: BigInt + "The tx hash of the moment the requester's appeal became fully funded." + txHashAppealFundedRequester: Bytes + "The tx hash of the moment the challenger's appeal became fully funded." + txHashAppealFundedChallenger: Bytes } type LContribution @entity { diff --git a/src/LightGeneralizedTCRMapping.ts b/src/LightGeneralizedTCRMapping.ts index b1eeb85..be41755 100644 --- a/src/LightGeneralizedTCRMapping.ts +++ b/src/LightGeneralizedTCRMapping.ts @@ -448,11 +448,23 @@ export function handleContribution(event: Contribution): void { event.params._roundID, ); + // Capture the previous fully-funded state so we can detect the transition + // from "partially funded" → "fully funded" and record the tx that caused it. + let wasFullyFundedRequester = round.hasPaidRequester; + let wasFullyFundedChallenger = round.hasPaidChallenger; + round.amountPaidRequester = roundInfo.value1[REQUESTER_CODE]; round.amountPaidChallenger = roundInfo.value1[CHALLENGER_CODE]; round.hasPaidRequester = roundInfo.value2[REQUESTER_CODE]; round.hasPaidChallenger = roundInfo.value2[CHALLENGER_CODE]; round.feeRewards = roundInfo.value3; + + if (!wasFullyFundedRequester && round.hasPaidRequester) { + round.txHashAppealFundedRequester = event.transaction.hash; + } + if (!wasFullyFundedChallenger && round.hasPaidChallenger) { + round.txHashAppealFundedChallenger = event.transaction.hash; + } } if (event.params._side === 1) { @@ -515,6 +527,8 @@ export function handleRequestChallenged(event: Dispute): void { request.challenger = requestInfo.value4[2]; request.numberOfRounds = BigInt.fromI32(2); request.disputeID = event.params._disputeID; + request.txHashChallenge = event.transaction.hash; + request.challengeTime = event.block.timestamp; let newRoundID = requestID + '-1'; // When a dispute is created, the new round is always id 1 let newRound = buildNewRound(newRoundID, request.id, event.block.timestamp);