From 880a07819cba256a140fe018b45263b6f9f894d0 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 4 Aug 2025 11:53:44 -0700 Subject: [PATCH 1/4] fix(Nostr Post): Opening up public post on page load --- src/components/app-body/nostr/feeds/index.js | 6 ++++-- src/components/app-body/nostr/nostr-post/index.js.js | 4 +++- src/components/app-body/nostr/nostr-post/public-post.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/app-body/nostr/feeds/index.js b/src/components/app-body/nostr/feeds/index.js index 9cd50c9..e01c6dc 100644 --- a/src/components/app-body/nostr/feeds/index.js +++ b/src/components/app-body/nostr/feeds/index.js @@ -1,13 +1,15 @@ /* -Component for reading the nostr feeds. + Component for reading the nostr feeds. */ // Global npm libraries import React, { useState, useEffect, useCallback } from 'react' import { Container, Nav, Tab, Spinner } from 'react-bootstrap' +import { RelayPool } from 'nostr' + +// Local libraries import Feed from './feed' import Following from './following' -import { RelayPool } from 'nostr' function Feeds (props) { const { appData } = props diff --git a/src/components/app-body/nostr/nostr-post/index.js.js b/src/components/app-body/nostr/nostr-post/index.js.js index dca4d1e..c16cc94 100644 --- a/src/components/app-body/nostr/nostr-post/index.js.js +++ b/src/components/app-body/nostr/nostr-post/index.js.js @@ -1,10 +1,12 @@ /* -Component for posting nostr information. + Component for posting nostr information. */ // Global npm libraries import React from 'react' import { Container } from 'react-bootstrap' + +// Local libraries import ProfilePost from './profile-post' import PublicPost from './public-post' diff --git a/src/components/app-body/nostr/nostr-post/public-post.js b/src/components/app-body/nostr/nostr-post/public-post.js index 7abd4c4..ec92d49 100644 --- a/src/components/app-body/nostr/nostr-post/public-post.js +++ b/src/components/app-body/nostr/nostr-post/public-post.js @@ -11,7 +11,7 @@ import { Relay } from 'nostr-tools/relay' import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency function PublicPost (props) { - const [accordionKey, setAccordionKey] = useState(null) + const [accordionKey, setAccordionKey] = useState('0') const [onFetch, setOnFetch] = useState(false) const { bchWalletState } = props.appData const [formData, setFormData] = useState({ From e547c97a447586fe5854334646977ba751979b07 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 4 Aug 2025 12:18:49 -0700 Subject: [PATCH 2/4] fix(Nostr Public Post): Posting to multiple Nostr relays --- .../app-body/nostr/nostr-post/public-post.js | 32 ++++++++++++------- src/config/index.js | 7 +++- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/components/app-body/nostr/nostr-post/public-post.js b/src/components/app-body/nostr/nostr-post/public-post.js index ec92d49..58f10f7 100644 --- a/src/components/app-body/nostr/nostr-post/public-post.js +++ b/src/components/app-body/nostr/nostr-post/public-post.js @@ -1,5 +1,5 @@ /* -Component for posting nostr information on kind 1. + Component for posting nostr information on kind 1. */ // Global npm libraries @@ -10,6 +10,9 @@ import { finalizeEvent } from 'nostr-tools/pure' import { Relay } from 'nostr-tools/relay' import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency +// Local libraries +import config from '../../../../config' + function PublicPost (props) { const [accordionKey, setAccordionKey] = useState('0') const [onFetch, setOnFetch] = useState(false) @@ -44,9 +47,6 @@ function PublicPost (props) { // Convert private key to binary const privateKeyBin = hexToBytes(nostrKeyPair.privHex) - // Relay list - const psf = 'wss://nostr-relay.psfoundation.info' - // BCH address of the user. const bchAddr = bchWalletState.address @@ -63,16 +63,24 @@ function PublicPost (props) { const signedEvent = finalizeEvent(eventTemplate, privateKeyBin) console.log('signedEvent: ', signedEvent) - // Connect to a relay. - const relay = await Relay.connect(psf) - console.log(`connected to ${relay.url}`) + // Publish the post to each relay. + config.nostrRelays.map(async (relayUrl) => { + try { + // Connect to a relay. + const relay = await Relay.connect(relayUrl) + console.log(`connected to ${relay.url}`) - // Publish the message to the relay. - const result = await relay.publish(signedEvent) - console.log('result: ', result) + // Publish the message to the relay. + const result = await relay.publish(signedEvent) + console.log('result: ', result) + + // Close the connection to the relay. + relay.close() + } catch (err) { + console.warn(`Skipping publishing to ${relayUrl} due to error: ${err}`) + } + }) - // Close the connection to the relay. - relay.close() resetForm() setSuccessMsg('Post successfully published!') setOnFetch(false) diff --git a/src/config/index.js b/src/config/index.js index 5635d6d..98a881a 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -18,7 +18,12 @@ const config = { // dexServer: 'http://localhost:5700', nostrTopic: 'bch-dex-test-topic-02', - nostrRelay: 'wss://nostr-relay.psfoundation.info' + nostrRelay: 'wss://nostr-relay.psfoundation.info', + nostrRelays: [ + 'wss://nostr-relay.psfoundation.info', + 'wss://nos.lol', + 'wss://relay.damus.io' + ] } From 44537e9cdd72601e12b316e93fb278c7486cf3d1 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 4 Aug 2025 12:22:19 -0700 Subject: [PATCH 3/4] fix(Nostr Profile Post): Posting to multiple relays --- .../app-body/nostr/nostr-post/profile-post.js | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/components/app-body/nostr/nostr-post/profile-post.js b/src/components/app-body/nostr/nostr-post/profile-post.js index d3b37e0..f89df41 100644 --- a/src/components/app-body/nostr/nostr-post/profile-post.js +++ b/src/components/app-body/nostr/nostr-post/profile-post.js @@ -11,6 +11,9 @@ import { Relay } from 'nostr-tools/relay' import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency import { RelayPool } from 'nostr' +// Local libraries +import config from '../../../../config' + function ProfilePost (props) { const { bchWalletState } = props.appData const [accordionKey, setAccordionKey] = useState(null) @@ -90,7 +93,7 @@ function ProfilePost (props) { const privateKeyBin = hexToBytes(nostrKeyPair.privHex) // Relay list - const psf = 'wss://nostr-relay.psfoundation.info' + // const psf = 'wss://nostr-relay.psfoundation.info' const formDataString = JSON.stringify(formData) @@ -107,16 +110,24 @@ function ProfilePost (props) { const signedEvent = finalizeEvent(eventTemplate, privateKeyBin) console.log('signedEvent: ', signedEvent) - // Connect to a relay. - const relay = await Relay.connect(psf) - console.log(`connected to ${relay.url}`) + // Publish the post to each relay. + config.nostrRelays.map(async (relayUrl) => { + try { + // Connect to a relay. + const relay = await Relay.connect(relayUrl) + console.log(`connected to ${relay.url}`) - // Publish the message to the relay. - const result = await relay.publish(signedEvent) - console.log('result: ', result) + // Publish the message to the relay. + const result = await relay.publish(signedEvent) + console.log('result: ', result) + + // Close the connection to the relay. + relay.close() + } catch (err) { + console.warn(`Skipping publishing to ${relayUrl} due to error: ${err}`) + } + }) - // Close the connection to the relay. - relay.close() setSuccessMsg('Post successfully published!') setOnFetch(false) } catch (error) { From 59f49f9813017bfe22328096b2f3bad203a5b03f Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 4 Aug 2025 12:37:41 -0700 Subject: [PATCH 4/4] fix(Token Info): Turning 'View User Data' link into a button --- src/components/app-body/nfts-for-sale/info-button.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/app-body/nfts-for-sale/info-button.js b/src/components/app-body/nfts-for-sale/info-button.js index c507b0a..663f572 100644 --- a/src/components/app-body/nfts-for-sale/info-button.js +++ b/src/components/app-body/nfts-for-sale/info-button.js @@ -98,17 +98,16 @@ function InfoButton (props) { {mutableDataCid && ( - + User Data: - View User Data - + )}