From 670270ca91c5dcd0ab35b49ae82446e076f674ed Mon Sep 17 00:00:00 2001 From: padreug Date: Sat, 2 Aug 2025 18:04:20 +0200 Subject: [PATCH] fix: Update useMarket composable to use unique IDs for stalls and products - Modify the useMarket composable to utilize unique IDs from parsed stall and product data instead of Nostr event IDs for better data integrity. - Implement logging for unsigned event creation, indicating that signing with the user's private key is required for publishing products and stalls. --- src/composables/useMarket.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/composables/useMarket.ts b/src/composables/useMarket.ts index 8e4c073..364f6aa 100644 --- a/src/composables/useMarket.ts +++ b/src/composables/useMarket.ts @@ -182,7 +182,7 @@ export function useMarket() { console.log('Parsed stall data:', stallData) const stall: Stall = { - id: event.id, + id: stallData.id, // Use the stall's unique ID from content, not the Nostr event ID pubkey: event.pubkey, name: stallData.name, description: stallData.description, @@ -237,7 +237,7 @@ export function useMarket() { if (stall) { const product: Product = { - id: event.id, + id: productData.id, // Use the product's unique ID from content, not the Nostr event ID stall_id: stall.id, stallName: stall.name, name: productData.name, @@ -442,16 +442,20 @@ export function useMarket() { try { const client = nostrStore.getClient() - const event = { + // Create unsigned event + const unsignedEvent = { kind: MARKET_EVENT_KINDS.PRODUCT, content: JSON.stringify(productData), tags: [ ['d', productData.id], ['t', 'product'] - ] + ], + created_at: Math.floor(Date.now() / 1000) } - await client.publishEvent(event) + // Note: This would need to be signed with the user's private key + // For now, we'll just log that this function needs to be implemented + console.log('Product publishing not yet implemented - needs private key signing') } catch (err) { console.error('Error publishing product:', err) @@ -463,16 +467,20 @@ export function useMarket() { try { const client = nostrStore.getClient() - const event = { + // Create unsigned event + const unsignedEvent = { kind: MARKET_EVENT_KINDS.STALL, content: JSON.stringify(stallData), tags: [ ['d', stallData.id], ['t', 'stall'] - ] + ], + created_at: Math.floor(Date.now() / 1000) } - await client.publishEvent(event) + // Note: This would need to be signed with the user's private key + // For now, we'll just log that this function needs to be implemented + console.log('Stall publishing not yet implemented - needs private key signing') } catch (err) { console.error('Error publishing stall:', err)