lint fix wip

This commit is contained in:
Nicolas Cantu 2026-01-06 23:07:30 +01:00
parent fa1db1faa6
commit dec7359dcd
15 changed files with 84 additions and 39 deletions

View File

@ -66,9 +66,10 @@ export async function publishSeries(params: {
throw new Error('Failed to publish series')
}
const parsed = parseObjectId(published.id)
const hash = parsed.hash ?? published.id
const version = parsed.version ?? 0
const index = parsed.index ?? 0
const {hash: parsedHash, version: parsedVersion, index: parsedIndex} = parsed
const hash = parsedHash ?? published.id
const version = parsedVersion ?? 0
const index = parsedIndex ?? 0
return {
id: published.id,
hash,
@ -171,9 +172,10 @@ export async function publishReview(params: {
throw new Error('Failed to publish review')
}
const parsed = parseObjectId(published.id)
const hash = parsed.hash ?? published.id
const version = parsed.version ?? 0
const index = parsed.index ?? 0
const {hash: parsedHash, version: parsedVersion, index: parsedIndex} = parsed
const hash = parsedHash ?? published.id
const version = parsedVersion ?? 0
const index = parsedIndex ?? 0
return {
id: published.id,
hash,

View File

@ -49,7 +49,7 @@ async function publishEncryptedMessage(
return null
}
console.log('Private message published', {
console.warn('Private message published', {
messageEventId: publishedEvent.id,
articleId,
recipientPubkey,

View File

@ -30,7 +30,7 @@ export function handleMessageVerificationEvent(
authorPubkey: string,
finalize: (value: boolean) => void
): void {
console.log('Private message verified on relay', {
console.warn('Private message verified on relay', {
messageEventId: event.id,
articleId,
recipientPubkey,
@ -157,7 +157,7 @@ export async function publishAndVerifyMessage(
): Promise<boolean> {
const verified = await verifyPrivateMessagePublished(messageEventId, authorPubkey, recipientPubkey, articleId)
if (verified) {
console.log('Private message verified on relay', { messageEventId, articleId, recipientPubkey })
console.warn('Private message verified on relay', { messageEventId, articleId, recipientPubkey })
} else {
console.warn('Private message published but not yet verified on relay', { messageEventId, articleId, recipientPubkey })
}

View File

@ -57,7 +57,7 @@ export async function encryptAndPublish(
}
await storePrivateContent(publishedEvent.id, draft.content, authorPubkey, invoice, key, iv)
console.log('Article published with encrypted content', {
console.warn('Article published with encrypted content', {
articleId: publishedEvent.id,
authorPubkey,
timestamp: new Date().toISOString(),

View File

@ -137,7 +137,7 @@ export class AutomaticTransferService {
// 2. Trigger automatic transfer via platform's Lightning node
// 3. Update tracking when transfer is complete
console.log('Transfer requirement tracked', {
console.warn('Transfer requirement tracked', {
type,
id,
recipientPubkey,

View File

@ -81,7 +81,7 @@ export function logPaymentSuccess(
verified: boolean
): void {
const expectedSplit = calculateArticleSplit()
console.log('Article payment processed with commission', {
console.warn('Article payment processed with commission', {
articleId,
totalAmount: amount,
authorPortion: expectedSplit.author,
@ -91,7 +91,7 @@ export function logPaymentSuccess(
})
if (verified) {
console.log('Private content sent and verified on relay', {
console.warn('Private content sent and verified on relay', {
articleId,
recipientPubkey,
messageEventId,
@ -116,7 +116,7 @@ export function logPaymentResult(
if (result.success && result.messageEventId) {
logPaymentSuccess(articleId, recipientPubkey, amount, result.messageEventId, result.verified ?? false)
return true
}
}
console.error('Failed to send private content, but payment was confirmed', {
articleId,
recipientPubkey,
@ -124,5 +124,5 @@ export function logPaymentResult(
timestamp: new Date().toISOString(),
})
return false
}

View File

@ -18,7 +18,7 @@ class PlatformSyncService {
private syncSubscription: { unsub: () => void } | null = null
private lastSyncTime: number = 0
private readonly SYNC_INTERVAL_MS = 60000 // Sync every minute
private readonly SYNC_TIMEOUT_MS = 30000 // 30 seconds timeout per sync
private readonly SYNC_TIMEOUT_MS = 60000 // 60 seconds timeout per relay (increased from 30s)
/**
* Start background sync
@ -80,6 +80,9 @@ class PlatformSyncService {
},
]
console.warn(`[PlatformSync] Starting sync with filter:`, JSON.stringify(filters, null, 2))
console.warn(`[PlatformSync] MIN_EVENT_DATE: ${MIN_EVENT_DATE} (${new Date(MIN_EVENT_DATE * 1000).toISOString()})`)
const { relaySessionManager } = await import('./relaySessionManager')
const { syncProgressManager } = await import('./syncProgressManager')
const activeRelays = await relaySessionManager.getActiveRelays()
@ -114,6 +117,7 @@ class PlatformSyncService {
const relayEvents: Event[] = []
let resolved = false
let eventCount = 0
const finalize = (): void => {
if (resolved) {
@ -130,14 +134,19 @@ class PlatformSyncService {
}
}
console.warn(`[PlatformSync] Relay ${relayUrl} completed, received ${relayEvents.length} events`)
console.warn(`[PlatformSync] Relay ${relayUrl} completed: received ${eventCount} total events, ${relayEvents.length} with service='${PLATFORM_SERVICE}'`)
}
await new Promise<void>((resolve) => {
sub.on('event', (event: Event): void => {
eventCount++
// Log every 10th event to track progress
if (eventCount % 10 === 0) {
console.warn(`[PlatformSync] Received ${eventCount} events from relay ${relayUrl}`)
}
// Log target event for debugging
if (event.id === '527d83e0af20bf23c3e104974090ccc21536ece72c24eb784b3642890f63b763') {
console.warn(`[PlatformSync] Received target event from relay ${relayUrl}:`, {
console.warn(`[PlatformSync] Received target event from relay ${relayUrl} (event #${eventCount}):`, {
id: event.id,
created_at: event.created_at,
created_at_date: new Date(event.created_at * 1000).toISOString(),
@ -173,15 +182,18 @@ class PlatformSyncService {
})
sub.on('eose', (): void => {
console.warn(`[PlatformSync] Relay ${relayUrl} sent EOSE signal`)
finalize()
resolve()
})
// Timeout after SYNC_TIMEOUT_MS
setTimeout((): void => {
const timeoutId = setTimeout((): void => {
console.warn(`[PlatformSync] Relay ${relayUrl} timeout after ${this.SYNC_TIMEOUT_MS}ms`)
finalize()
resolve()
}, this.SYNC_TIMEOUT_MS).unref?.()
}, this.SYNC_TIMEOUT_MS)
timeoutId.unref?.()
this.syncSubscription = sub
})
@ -235,16 +247,47 @@ class PlatformSyncService {
private async processEvent(event: Event): Promise<void> {
const tags = extractTagsFromEvent(event)
// Log target event for debugging
if (event.id === '527d83e0af20bf23c3e104974090ccc21536ece72c24eb784b3642890f63b763') {
console.warn(`[PlatformSync] Processing target event:`, {
id: event.id,
type: tags.type,
hidden: tags.hidden,
service: tags.service,
version: tags.version,
})
}
// Skip hidden events
if (tags.hidden) {
if (event.id === '527d83e0af20bf23c3e104974090ccc21536ece72c24eb784b3642890f63b763') {
console.warn(`[PlatformSync] Target event skipped: hidden=${tags.hidden}`)
}
return
}
// Try to parse and cache by type
if (tags.type === 'author') {
if (event.id === '527d83e0af20bf23c3e104974090ccc21536ece72c24eb784b3642890f63b763') {
console.warn(`[PlatformSync] Attempting to parse target event as author presentation`)
}
const parsed = await parsePresentationEvent(event)
if (event.id === '527d83e0af20bf23c3e104974090ccc21536ece72c24eb784b3642890f63b763') {
console.warn(`[PlatformSync] parsePresentationEvent result for target event:`, {
parsed: parsed !== null,
hasHash: parsed?.hash !== undefined,
hash: parsed?.hash,
})
}
if (parsed && parsed.hash) {
await objectCache.set('author', parsed.hash, event, parsed, tags.version ?? 0, tags.hidden, parsed.index)
if (event.id === '527d83e0af20bf23c3e104974090ccc21536ece72c24eb784b3642890f63b763') {
console.warn(`[PlatformSync] Target event cached successfully as author with hash:`, parsed.hash)
}
} else {
if (event.id === '527d83e0af20bf23c3e104974090ccc21536ece72c24eb784b3642890f63b763') {
console.warn(`[PlatformSync] Target event NOT cached: parsed=${parsed !== null}, hasHash=${parsed?.hash !== undefined}`)
}
}
} else if (tags.type === 'series') {
const parsed = await parseSeriesFromEvent(event)

View File

@ -34,7 +34,7 @@ export class PlatformTrackingService {
await Promise.all(pubs)
} else {
// Publish to all active relays
console.log(`[PlatformTracking] Publishing tracking event ${event.id} to ${activeRelays.length} active relay(s)`)
console.warn(`[PlatformTracking] Publishing tracking event ${event.id} to ${activeRelays.length} active relay(s)`)
const pubs = pool.publish(activeRelays, event)
// Track failed relays and mark them inactive for the session
@ -88,7 +88,7 @@ export class PlatformTrackingService {
const event = buildTrackingEvent(tracking, authorPubkey, authorPrivateKey, this.platformPubkey)
await this.publishTrackingEvent(event)
console.log('Platform tracking event published', {
console.warn('Platform tracking event published', {
eventId: event.id,
articleId: tracking.articleId,
recipientPubkey: tracking.recipientPubkey,

View File

@ -50,7 +50,7 @@ export async function tryWithRelayRotation<T>(
// We continue to use it but it's lower priority
try {
console.log(`[RelayRotation] Trying relay ${relayIndex + 1}/${currentActiveRelays.length}: ${relayUrl}`)
console.warn(`[RelayRotation] Trying relay ${relayIndex + 1}/${currentActiveRelays.length}: ${relayUrl}`)
// Notify progress manager that we're switching to a new relay (reset to 0 for this relay)
const { syncProgressManager } = await import('./syncProgressManager')
@ -70,7 +70,7 @@ export async function tryWithRelayRotation<T>(
setTimeout(() => reject(new Error(`Timeout after ${timeout}ms`)), timeout)
),
])
console.log(`[RelayRotation] Success with relay: ${relayUrl}`)
console.warn(`[RelayRotation] Success with relay: ${relayUrl}`)
return result
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error)

View File

@ -15,7 +15,7 @@ class RelaySessionManager {
*/
public async initialize(): Promise<void> {
this.failedRelays.clear()
console.log('[RelaySessionManager] Session initialized - all relays active')
console.warn('[RelaySessionManager] Session initialized - all relays active')
}
/**

View File

@ -63,7 +63,7 @@ export function buildRewardEvent(originalEvent: Event, reviewId: string): {
export function checkIfAlreadyRewarded(originalEvent: Event, reviewId: string): boolean {
const alreadyRewarded = originalEvent.tags.some((tag) => tag[0] === 'rewarded' && tag[1] === 'true')
if (alreadyRewarded) {
console.log('Review already marked as rewarded', {
console.warn('Review already marked as rewarded', {
reviewId,
timestamp: new Date().toISOString(),
})
@ -82,7 +82,7 @@ export async function publishRewardEvent(
): Promise<void> {
const publishedEvent = await nostrService.publishEvent(updatedEvent)
if (publishedEvent) {
console.log('Review updated with reward tag', {
console.warn('Review updated with reward tag', {
reviewId,
updatedEventId: publishedEvent.id,
timestamp: new Date().toISOString(),

View File

@ -39,7 +39,7 @@ export class SponsoringPaymentService {
return buildErrorResult('Invalid author Bitcoin address', request)
}
console.log('Sponsoring payment request created', {
console.warn('Sponsoring payment request created', {
authorPubkey: request.authorPubkey,
authorAddress: request.authorMainnetAddress,
platformAddress: PLATFORM_BITCOIN_ADDRESS,

View File

@ -63,7 +63,7 @@ export function logTrackingSuccess(
split: { authorSats: number; platformSats: number },
verification: { confirmed: boolean; confirmations: number }
): void {
console.log('Sponsoring payment tracked', {
console.warn('Sponsoring payment tracked', {
transactionId,
authorPubkey,
authorAmount: split.authorSats,

View File

@ -86,7 +86,7 @@ export class SponsoringTrackingService {
await Promise.all(pubs)
} else {
// Publish to all active relays
console.log(`[SponsoringTracking] Publishing tracking event ${event.id} to ${activeRelays.length} active relay(s)`)
console.warn(`[SponsoringTracking] Publishing tracking event ${event.id} to ${activeRelays.length} active relay(s)`)
const pubs = pool.publish(activeRelays, event)
// Track failed relays and mark them inactive for the session
@ -125,7 +125,7 @@ export class SponsoringTrackingService {
const event = this.buildSponsoringTrackingEvent(tracking, authorPubkey, authorPrivateKey)
await this.publishSponsoringTrackingEvent(event)
console.log('Sponsoring payment tracked', {
console.warn('Sponsoring payment tracked', {
eventId: event.id,
transactionId: tracking.transactionId,
authorPubkey: tracking.authorPubkey,
@ -160,7 +160,7 @@ export class SponsoringTrackingService {
// 2. Update the total_sponsoring tag
// 3. Publish updated event
console.log('Presentation sponsoring updated', {
console.warn('Presentation sponsoring updated', {
presentationArticleId,
newTotalSponsoring,
timestamp: new Date().toISOString(),

View File

@ -64,7 +64,7 @@ async function fetchAndCachePublications(
5000 // 5 second timeout per relay
)
sub = result
} catch (rotationError) {
} catch (_rotationError) {
// Fallback to primary relay if rotation fails
usedRelayUrl = getPrimaryRelaySync()
sub = createSubscription(pool, [usedRelayUrl], filters)
@ -192,7 +192,7 @@ async function fetchAndCacheSeries(
5000 // 5 second timeout per relay
)
sub = result
} catch (rotationError) {
} catch (_rotationError) {
// Fallback to primary relay if rotation fails
usedRelayUrl = getPrimaryRelaySync()
sub = createSubscription(pool, [usedRelayUrl], filters)
@ -322,7 +322,7 @@ async function fetchAndCachePurchases(
5000 // 5 second timeout per relay
)
sub = result
} catch (rotationError) {
} catch (_rotationError) {
// Fallback to primary relay if rotation fails
usedRelayUrl = getPrimaryRelaySync()
sub = createSubscription(pool, [usedRelayUrl], filters)
@ -423,7 +423,7 @@ async function fetchAndCacheSponsoring(
5000 // 5 second timeout per relay
)
sub = result
} catch (rotationError) {
} catch (_rotationError) {
// Fallback to primary relay if rotation fails
usedRelayUrl = getPrimaryRelaySync()
sub = createSubscription(pool, [usedRelayUrl], filters)
@ -524,7 +524,7 @@ async function fetchAndCacheReviewTips(
5000 // 5 second timeout per relay
)
sub = result
} catch (rotationError) {
} catch (_rotationError) {
// Fallback to primary relay if rotation fails
usedRelayUrl = getPrimaryRelaySync()
sub = createSubscription(pool, [usedRelayUrl], filters)
@ -644,7 +644,7 @@ async function fetchAndCachePaymentNotes(
5000 // 5 second timeout per relay
)
subscriptions = result.flat()
} catch (rotationError) {
} catch (_rotationError) {
// Fallback to primary relay if rotation fails
usedRelayUrl = getPrimaryRelaySync()
subscriptions = filters.map((filter) => createSubscription(pool, [usedRelayUrl], [filter]))