Skip to content

Commit

Permalink
fix: queue backfill job for signer app profile
Browse files Browse the repository at this point in the history
  • Loading branch information
stephancill committed Jan 9, 2025
1 parent a80ffa5 commit a0fa257
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/api/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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: {
Expand Down
10 changes: 10 additions & 0 deletions src/lib/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
HubEventType,
MessageType,
OnChainEventType,
extractEventTimestamp,
isMergeOnChainHubEvent,
isSignerOnChainEvent,
} from '@farcaster/hub-nodejs'
Expand Down Expand Up @@ -45,10 +46,19 @@ export async function handleEventJob(job: Job<Buffer>) {
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(
Expand Down

0 comments on commit a0fa257

Please sign in to comment.