diff --git a/dev-docs/README.md b/dev-docs/README.md index 8ff17ee..020baf7 100644 --- a/dev-docs/README.md +++ b/dev-docs/README.md @@ -9,3 +9,20 @@ This file contains notes taken during software development. These notes may even - [minimal-slp-wallet](https://www.npmjs.com/package/minimal-slp-wallet) is used to access tokens and BCH on the Bitcoin Cash blockchain. - A 'server selection' dropdown allows the user to select from an array of redundent back end servers. - This site is statically compiled, uploaded to Filecoin, and served over IPFS for censorship resistance and version control. + +## File Layout + +The top-level file layout of this app looks like this: + +- App.js - the main application orchestates these child components: + - GetRestUrl - retrieves the REST URL for the selected back-end web3 server from query paramenters in the URL. + - LoadScripts - Loads the modal with a waiting spinner animation until the external script files are loaded. + - NavMenu - the collapsible navigation menu + - InitializedView & UnitializedView - the default Views that are displayed depending on the state of the app. + - ServerSelect - allows the user to select a different web3 back end server. + - Footer - Footer links + +After initialization, the InitailizedView is displayed. This loads the AppBody, which is a wrapper for each View. Views are selected using the navigation menu. When one View is selected, the others are hidden. + +## Loading of Wallet +The wallet library [minimal-slp-wallet](https://www.npmjs.com/package/minimal-slp-wallet) is loaded at startup, and initialized with a web3 back end server. By default, the back-end server is free-bch.fullstack.cash. However, a list of back end servers provided by the [PSF](https://psfoundation.cash) are loaded into a drop-down from a GitHub diff --git a/src/App.js b/src/App.js index 3ae60b7..026e828 100644 --- a/src/App.js +++ b/src/App.js @@ -18,7 +18,8 @@ import NavMenu from './components/nav-menu' import AppBody from './components/app-body' // Default restURL for a back-end server. -let serverURL = 'https://free-bch.fullstack.cash' +let serverUrl = 'https://free-bch.fullstack.cash' +let queryParamExists = false let _this @@ -37,7 +38,9 @@ class App extends React.Component { wallet: false, modalBody: this.modalBody, hideSpinner: false, - menuState: 0 + menuState: 0, + queryParamExists: false, + serverUrl } this.cnt = 0 @@ -52,12 +55,16 @@ class App extends React.Component { await this.asyncLoad.loadWalletLib() this.addToModal('Initializing wallet') + // console.log(`Initializing wallet with back end server ${serverUrl}`) + // console.log(`queryParamExists: ${queryParamExists}`) - const wallet = await this.asyncLoad.initWallet(serverURL) + const wallet = await this.asyncLoad.initWallet(serverUrl) this.setState({ wallet, - walletInitialized: true + walletInitialized: true, + serverUrl, + queryParamExists }) } catch (err) { this.modalBody = [ @@ -75,6 +82,7 @@ class App extends React.Component { render () { // console.log('App component rendered. this.state.wallet: ', this.state.wallet) // console.log(`App component menuState: ${this.state.menuState}`) + // console.log(`render() this.state.serverUrl: ${this.state.serverUrl}`) return ( <> @@ -82,7 +90,7 @@ class App extends React.Component { {this.state.walletInitialized ? : } - +