From 803df2d22ba4a821480812c59ceaaa9d241492fd Mon Sep 17 00:00:00 2001 From: Gigi Date: Tue, 7 Oct 2025 05:46:20 +0100 Subject: [PATCH] refactor: use AppDataBlueprint via namespace import - Import blueprints as namespace: 'import * as Blueprints from applesauce-factory/blueprints' - Use Blueprints.AppDataBlueprint with proper factory API - Cleaner than manual event construction - Should work with Vercel as namespace imports don't require direct named exports --- src/services/settingsService.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/services/settingsService.ts b/src/services/settingsService.ts index 8d4f4bc9..83c547de 100644 --- a/src/services/settingsService.ts +++ b/src/services/settingsService.ts @@ -3,6 +3,7 @@ import { EventFactory } from 'applesauce-factory' import { RelayPool, onlyEvents } from 'applesauce-relay' import { NostrEvent } from 'nostr-tools' import { firstValueFrom } from 'rxjs' +import * as Blueprints from 'applesauce-factory/blueprints' const SETTINGS_IDENTIFIER = 'com.dergigi.boris.user-settings' const APP_DATA_KIND = 30078 // NIP-78 Application Data @@ -136,13 +137,13 @@ export async function saveSettings( ): Promise { console.log('💾 Saving settings to nostr:', settings) - // Create NIP-78 application data event manually - const draft = await factory.create(async () => ({ - kind: APP_DATA_KIND, - content: JSON.stringify(settings), - tags: [['d', SETTINGS_IDENTIFIER]], - created_at: Math.floor(Date.now() / 1000) - })) + // Create NIP-78 application data event using the AppDataBlueprint + const draft = await factory.create( + Blueprints.AppDataBlueprint, + SETTINGS_IDENTIFIER, + settings, + false // no encryption + ) const signed = await factory.sign(draft)