mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex-taker-v2.git
synced 2026-09-21 16:52:01 -07:00
Merge pull request #44 from Permissionless-Software-Foundation/ct-unstable
Minor design improvements
This commit is contained in:
@@ -98,17 +98,16 @@ function InfoButton (props) {
|
|||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
{mutableDataCid && (
|
{mutableDataCid && (
|
||||||
<Row>
|
<Row style={{ paddingTop: '10px' }}>
|
||||||
<Col xs={4}><b>User Data</b>:</Col>
|
<Col xs={4}><b>User Data</b>:</Col>
|
||||||
<Col xs={8}>
|
<Col xs={8}>
|
||||||
<a
|
<Button
|
||||||
href={`/user-data/${props.token.tokenId}#single-view`}
|
href={`/user-data/${props.token.tokenId}#single-view`}
|
||||||
target='_blank'
|
target='_blank'
|
||||||
rel='noopener noreferrer'
|
rel='noopener noreferrer'
|
||||||
className='btn btn-link p-0'
|
|
||||||
>
|
>
|
||||||
View User Data
|
View User Data
|
||||||
</a>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
Component for reading the nostr feeds.
|
Component for reading the nostr feeds.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Global npm libraries
|
// Global npm libraries
|
||||||
import React, { useState, useEffect, useCallback } from 'react'
|
import React, { useState, useEffect, useCallback } from 'react'
|
||||||
import { Container, Nav, Tab, Spinner } from 'react-bootstrap'
|
import { Container, Nav, Tab, Spinner } from 'react-bootstrap'
|
||||||
|
import { RelayPool } from 'nostr'
|
||||||
|
|
||||||
|
// Local libraries
|
||||||
import Feed from './feed'
|
import Feed from './feed'
|
||||||
import Following from './following'
|
import Following from './following'
|
||||||
import { RelayPool } from 'nostr'
|
|
||||||
|
|
||||||
function Feeds (props) {
|
function Feeds (props) {
|
||||||
const { appData } = props
|
const { appData } = props
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
Component for posting nostr information.
|
Component for posting nostr information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Global npm libraries
|
// Global npm libraries
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Container } from 'react-bootstrap'
|
import { Container } from 'react-bootstrap'
|
||||||
|
|
||||||
|
// Local libraries
|
||||||
import ProfilePost from './profile-post'
|
import ProfilePost from './profile-post'
|
||||||
import PublicPost from './public-post'
|
import PublicPost from './public-post'
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import { Relay } from 'nostr-tools/relay'
|
|||||||
import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency
|
import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency
|
||||||
import { RelayPool } from 'nostr'
|
import { RelayPool } from 'nostr'
|
||||||
|
|
||||||
|
// Local libraries
|
||||||
|
import config from '../../../../config'
|
||||||
|
|
||||||
function ProfilePost (props) {
|
function ProfilePost (props) {
|
||||||
const { bchWalletState } = props.appData
|
const { bchWalletState } = props.appData
|
||||||
const [accordionKey, setAccordionKey] = useState(null)
|
const [accordionKey, setAccordionKey] = useState(null)
|
||||||
@@ -90,7 +93,7 @@ function ProfilePost (props) {
|
|||||||
const privateKeyBin = hexToBytes(nostrKeyPair.privHex)
|
const privateKeyBin = hexToBytes(nostrKeyPair.privHex)
|
||||||
|
|
||||||
// Relay list
|
// Relay list
|
||||||
const psf = 'wss://nostr-relay.psfoundation.info'
|
// const psf = 'wss://nostr-relay.psfoundation.info'
|
||||||
|
|
||||||
const formDataString = JSON.stringify(formData)
|
const formDataString = JSON.stringify(formData)
|
||||||
|
|
||||||
@@ -107,16 +110,24 @@ function ProfilePost (props) {
|
|||||||
const signedEvent = finalizeEvent(eventTemplate, privateKeyBin)
|
const signedEvent = finalizeEvent(eventTemplate, privateKeyBin)
|
||||||
console.log('signedEvent: ', signedEvent)
|
console.log('signedEvent: ', signedEvent)
|
||||||
|
|
||||||
// Connect to a relay.
|
// Publish the post to each relay.
|
||||||
const relay = await Relay.connect(psf)
|
config.nostrRelays.map(async (relayUrl) => {
|
||||||
console.log(`connected to ${relay.url}`)
|
try {
|
||||||
|
// Connect to a relay.
|
||||||
|
const relay = await Relay.connect(relayUrl)
|
||||||
|
console.log(`connected to ${relay.url}`)
|
||||||
|
|
||||||
// Publish the message to the relay.
|
// Publish the message to the relay.
|
||||||
const result = await relay.publish(signedEvent)
|
const result = await relay.publish(signedEvent)
|
||||||
console.log('result: ', result)
|
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!')
|
setSuccessMsg('Post successfully published!')
|
||||||
setOnFetch(false)
|
setOnFetch(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Component for posting nostr information on kind 1.
|
Component for posting nostr information on kind 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Global npm libraries
|
// Global npm libraries
|
||||||
@@ -10,8 +10,11 @@ import { finalizeEvent } from 'nostr-tools/pure'
|
|||||||
import { Relay } from 'nostr-tools/relay'
|
import { Relay } from 'nostr-tools/relay'
|
||||||
import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency
|
import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency
|
||||||
|
|
||||||
|
// Local libraries
|
||||||
|
import config from '../../../../config'
|
||||||
|
|
||||||
function PublicPost (props) {
|
function PublicPost (props) {
|
||||||
const [accordionKey, setAccordionKey] = useState(null)
|
const [accordionKey, setAccordionKey] = useState('0')
|
||||||
const [onFetch, setOnFetch] = useState(false)
|
const [onFetch, setOnFetch] = useState(false)
|
||||||
const { bchWalletState } = props.appData
|
const { bchWalletState } = props.appData
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
@@ -44,9 +47,6 @@ function PublicPost (props) {
|
|||||||
// Convert private key to binary
|
// Convert private key to binary
|
||||||
const privateKeyBin = hexToBytes(nostrKeyPair.privHex)
|
const privateKeyBin = hexToBytes(nostrKeyPair.privHex)
|
||||||
|
|
||||||
// Relay list
|
|
||||||
const psf = 'wss://nostr-relay.psfoundation.info'
|
|
||||||
|
|
||||||
// BCH address of the user.
|
// BCH address of the user.
|
||||||
const bchAddr = bchWalletState.address
|
const bchAddr = bchWalletState.address
|
||||||
|
|
||||||
@@ -63,16 +63,24 @@ function PublicPost (props) {
|
|||||||
const signedEvent = finalizeEvent(eventTemplate, privateKeyBin)
|
const signedEvent = finalizeEvent(eventTemplate, privateKeyBin)
|
||||||
console.log('signedEvent: ', signedEvent)
|
console.log('signedEvent: ', signedEvent)
|
||||||
|
|
||||||
// Connect to a relay.
|
// Publish the post to each relay.
|
||||||
const relay = await Relay.connect(psf)
|
config.nostrRelays.map(async (relayUrl) => {
|
||||||
console.log(`connected to ${relay.url}`)
|
try {
|
||||||
|
// Connect to a relay.
|
||||||
|
const relay = await Relay.connect(relayUrl)
|
||||||
|
console.log(`connected to ${relay.url}`)
|
||||||
|
|
||||||
// Publish the message to the relay.
|
// Publish the message to the relay.
|
||||||
const result = await relay.publish(signedEvent)
|
const result = await relay.publish(signedEvent)
|
||||||
console.log('result: ', result)
|
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()
|
resetForm()
|
||||||
setSuccessMsg('Post successfully published!')
|
setSuccessMsg('Post successfully published!')
|
||||||
setOnFetch(false)
|
setOnFetch(false)
|
||||||
|
|||||||
+6
-1
@@ -18,7 +18,12 @@ const config = {
|
|||||||
// dexServer: 'http://localhost:5700',
|
// dexServer: 'http://localhost:5700',
|
||||||
|
|
||||||
nostrTopic: 'bch-dex-test-topic-02',
|
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'
|
||||||
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user