From a0fa257c78f47880fd5bfc89fa82e708677462ca Mon Sep 17 00:00:00 2001 From: Stephan Cilliers <5469870+stephancill@users.noreply.github.com> Date: Thu, 9 Jan 2025 19:13:12 +0200 Subject: [PATCH] fix: queue backfill job for signer app profile --- src/api/signer.ts | 8 ++++++++ src/lib/event.ts | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/api/signer.ts b/src/api/signer.ts index b5af0e4..806f5e3 100644 --- a/src/api/signer.ts +++ b/src/api/signer.ts @@ -7,6 +7,7 @@ import { import { bytesToHex, decodeAbiParameters } from 'viem' import { db } from '../db/db.js' +import { getBackfillQueue, queueBackfillJob } from '../lib/backfill.js' import { hubClient } from '../lib/hub-client.js' import { getOnChainEventsByFidInBatchesOf } from '../lib/paginate.js' import { MAX_PAGE_SIZE } from '../lib/utils.js' @@ -105,6 +106,13 @@ export async function insertSigners(signers: OnChainEvent[]) { ) .execute() + // Backfill profile of app requesting key + const queue = getBackfillQueue() + queueBackfillJob(metadataJson.requestFid, queue, { + partial: true, + priority: 110, + }) + break } case SignerEventType.REMOVE: { diff --git a/src/lib/event.ts b/src/lib/event.ts index 1923b72..9099423 100644 --- a/src/lib/event.ts +++ b/src/lib/event.ts @@ -3,6 +3,7 @@ import { HubEventType, MessageType, OnChainEventType, + extractEventTimestamp, isMergeOnChainHubEvent, isSignerOnChainEvent, } from '@farcaster/hub-nodejs' @@ -45,10 +46,19 @@ export async function handleEventJob(job: Job) { export async function handleEvent(event: HubEvent) { let isAppSignerEvent = false + const timestamp = extractEventTimestamp(event.id) + + if (isMergeOnChainHubEvent(event)) { + log.debug( + `Event timestamp: ${new Date(timestamp).toISOString()} type: ${event.type}` + ) + } + if ( isMergeOnChainHubEvent(event) && isSignerOnChainEvent(event.mergeOnChainEventBody.onChainEvent) ) { + log.debug('Processing signer event') try { const { requestFid: appFid, requestSigner: appSigner } = decodeSignedKeyRequestMetadata(