diff --git a/public/index.html b/public/index.html
index d405b6a..13c8793 100644
--- a/public/index.html
+++ b/public/index.html
@@ -3,7 +3,7 @@
- React-Bootstrap CodeSandbox Starter
+ BCH Web3 Template
diff --git a/src/App.js b/src/App.js
index af2350a..4024112 100644
--- a/src/App.js
+++ b/src/App.js
@@ -10,18 +10,18 @@ import { useQueryParam, StringParam } from 'use-query-params'
// Local libraries
import './App.css'
import LoadScripts from './components/load-scripts'
-import NFTs from './components/nfts'
+// import NFTs from './components/nfts'
import WaitingModal from './components/waiting-modal'
import AsyncLoad from './services/async-load'
import ServerSelect from './components/servers'
import Footer from './components/footer'
-
-// Token ID for Trout's NFTs
-const groupTokenId = '030563ddd65772d8e9b79b825529ed53c7d27037507b57c528788612b4911107'
+import GetBalance from './components/balance'
// Default restURL for a back-end server.
let serverURL = 'https://free-bch.fullstack.cash'
+let _this
+
class App extends React.Component {
constructor (props) {
super(props)
@@ -41,6 +41,8 @@ class App extends React.Component {
}
this.cnt = 0
+
+ _this = this
}
async componentDidMount () {
@@ -53,26 +55,26 @@ class App extends React.Component {
const wallet = await this.asyncLoad.initWallet(serverURL)
- this.addToModal('Getting Group Token Information')
+ // this.addToModal('Getting Group Token Information')
// Get Group Token info
- const groupData = await this.asyncLoad.getGroupData(groupTokenId)
+ // const groupData = await this.asyncLoad.getGroupData(groupTokenId)
// console.log(`groupData: ${JSON.stringify(groupData, null, 2)}`)
- this.addToModal('Getting NFT Information')
+ // this.addToModal('Getting NFT Information')
/// Get NFT child info
- const nftData = []
- for (let i = 0; i < groupData.nfts.length; i++) {
- const tokenData = await this.asyncLoad.getTokenData(groupData.nfts[i])
- nftData.push(tokenData)
- }
+ // const nftData = []
+ // for (let i = 0; i < groupData.nfts.length; i++) {
+ // const tokenData = await this.asyncLoad.getTokenData(groupData.nfts[i])
+ // nftData.push(tokenData)
+ // }
// console.log(`nft data: ${JSON.stringify(nftData, null, 2)}`)
- this.tokenData = {
- groupData,
- nftData
- }
+ // this.tokenData = {
+ // groupData,
+ // nftData
+ // }
this.setState({
wallet,
@@ -81,7 +83,7 @@ class App extends React.Component {
} catch (err) {
this.modalBody = [
`Error: ${err.message}`,
- `Try selecting a different back end server using the drop-down menu at the bottom of the app.`
+ 'Try selecting a different back end server using the drop-down menu at the bottom of the app.'
]
this.setState({
@@ -98,7 +100,7 @@ class App extends React.Component {
<>
- {this.state.walletInitialized ? : }
+ {this.state.walletInitialized ? : }
>
@@ -125,7 +127,7 @@ function UninitializedView (props) {
- NFT Explorer
+ PSF Web3 Demo
@@ -141,11 +143,11 @@ function InitializedView (props) {
- NFT Explorer
+ PSF Web3 Demo
-
+
>
)
}
diff --git a/src/components/balance.js b/src/components/balance.js
new file mode 100644
index 0000000..bab20a0
--- /dev/null
+++ b/src/components/balance.js
@@ -0,0 +1,82 @@
+/*
+ Component for looking up the balance of a BCH address.
+*/
+
+// Global npm libraries
+import React from 'react'
+import { Container, Row, Col, Form, Button, Spinner } from 'react-bootstrap'
+
+let _this
+
+class GetBalance extends React.Component {
+ constructor(props) {
+ super(props)
+
+ this.state = {
+ balance: '',
+ textInput: '',
+ wallet: props.wallet
+ }
+
+ _this = this
+ }
+
+ render () {
+ return (
+
+ <>
+
+
+
+
+ Enter a BCH address to check the balance.
+ this.setState({textInput: e.target.value})} />
+
+
+
+
+
+
+
+
+
+ {this.state.balance}
+
+
+
+ >
+ )
+ }
+
+ async getBalance(event) {
+ try {
+ const textInput = _this.state.textInput
+
+ // Exit on invalid input
+ if(!textInput) return
+ if(!textInput.includes('bitcoincash:')) return
+
+ _this.setState({
+ balance: (Retrieving balance... )
+ })
+
+ const balance = await _this.state.wallet.getBalance(textInput)
+ console.log('balance: ', balance)
+
+ const bchBalance = _this.state.wallet.bchjs.BitcoinCash.toBitcoinCash(balance)
+
+ _this.setState({
+ balance: `Balance: ${balance} sats, ${bchBalance} BCH`
+ })
+ } catch(err) {
+ _this.setState({
+ balance: `Error: ${err.message}`
+ })
+ }
+ }
+}
+
+export default GetBalance
diff --git a/src/components/footer.js b/src/components/footer.js
index d33cbf5..bd559b2 100644
--- a/src/components/footer.js
+++ b/src/components/footer.js
@@ -6,7 +6,7 @@
import React from 'react'
import { Container, Row, Col } from 'react-bootstrap'
-const IPFS_CID = 'bafybeiff7sjpdizarbtjgc3ftefyzndggsx3uxqs7l42ruzcwdkbuld6eq'
+const IPFS_CID = 'bafybeie6gh5bngwne63tycok3okrh5i6dxt7xaoby62psjkvt7n7pl2ou4'
class Footer extends React.Component {
render () {
@@ -16,13 +16,10 @@ class Footer extends React.Component {
Site Mirrors
-
-
Source Code