feat(site-config.js): Using to switch between dectralized and centralized infra

This commit is contained in:
Chris Troutner
2022-02-03 06:27:21 -08:00
parent 6162119aa9
commit 27c1994fd8
3 changed files with 76 additions and 58 deletions
+22 -18
View File
@@ -60,18 +60,18 @@ class AdminLTEPage extends React.Component {
<AdminLTE <AdminLTE
title={[siteConfig.title]} title={[siteConfig.title]}
titleShort={[siteConfig.titleShort]} titleShort={[siteConfig.titleShort]}
theme='blue' theme="blue"
> >
<Sidebar.Core> <Sidebar.Core>
<Item key='Balance' text='Balance' icon={siteConfig.balanceIcon}> <Item key="Balance" text="Balance" icon={siteConfig.balanceIcon}>
<Box <Box
className='hover-shadow border-none background-none' className="hover-shadow border-none background-none"
loaded={!_this.state.inFetch} loaded={!_this.state.inFetch}
> >
<div className='sidebar-balance'> <div className="sidebar-balance">
<div> <div>
{!_this.state.inFetch && ( {!_this.state.inFetch && (
<div className='siderbar-balance-content'> <div className="siderbar-balance-content">
<span> <span>
<h3>{siteConfig.balanceText}</h3> <h3>{siteConfig.balanceText}</h3>
@@ -81,9 +81,9 @@ class AdminLTEPage extends React.Component {
<small>USD: ${_this.state.usdBalance}</small> <small>USD: ${_this.state.usdBalance}</small>
</span> </span>
<FontAwesomeIcon <FontAwesomeIcon
className='ml-1 icon' className="ml-1 icon"
size='lg' size="lg"
icon='redo' icon="redo"
onClick={_this.handleGetBalance} onClick={_this.handleGetBalance}
/> />
</div> </div>
@@ -101,8 +101,8 @@ class AdminLTEPage extends React.Component {
<Navbar.Core> <Navbar.Core>
<VersionStatus /> <VersionStatus />
</Navbar.Core> </Navbar.Core>
<Layout path='/' {..._this.props}> <Layout path="/" {..._this.props}>
<div className='components-container'> <div className="components-container">
{_this.renderNewViewItems(_this.props)} {_this.renderNewViewItems(_this.props)}
</div> </div>
</Layout> </Layout>
@@ -134,14 +134,18 @@ class AdminLTEPage extends React.Component {
const bchjs = bchWalletLib.bchjs const bchjs = bchWalletLib.bchjs
let currentRate const currentRate = (await bchWalletLib.getUsd()) * 100
console.log('currentRate: ', currentRate)
if (bchjs.restURL.includes('abc.fullstack')) { // if (bchjs.restURL.includes('abc.fullstack')) {
currentRate = (await bchjs.Price.getBchaUsd()) * 100 // currentRate = (await bchjs.Price.getBchaUsd()) * 100
} else { // } else if (siteConfig.interface === 'consumer-api') {
// BCHN price. // bchjs.restURL = `${siteConfig.restURL}/`
currentRate = (await bchjs.Price.getUsd()) * 100 // currentRate = (await bchjs.Price.getUsd()) * 100
} // } else {
// // BCHN price.
// currentRate = (await bchjs.Price.getUsd()) * 100
// }
_this.setState({ _this.setState({
currentRate: currentRate currentRate: currentRate
@@ -383,7 +387,7 @@ class AdminLTEPage extends React.Component {
return ( return (
<li style={{ display: 'none' }}> <li style={{ display: 'none' }}>
{/* Adding this childrens prevents console errors */} {/* Adding this childrens prevents console errors */}
<a href='#'> <a href="#">
<span /> <span />
<span /> <span />
</a> </a>
+52 -39
View File
@@ -6,6 +6,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import ScannerModal from '../../qr-scanner/modal' import ScannerModal from '../../qr-scanner/modal'
const { Text } = Inputs const { Text } = Inputs
const siteConfig = require('../../site-config')
const BchWallet = typeof window !== 'undefined' ? window.SlpWallet : null const BchWallet = typeof window !== 'undefined' ? window.SlpWallet : null
let _this let _this
@@ -33,72 +35,72 @@ class SendTokens extends React.Component {
<> <>
<Row> <Row>
<Col sm={12}> <Col sm={12}>
<Box className=' border-none mt-2' loaded={!this.state.inFetch}> <Box className=" border-none mt-2" loaded={!this.state.inFetch}>
<Row> <Row>
<Col sm={12} className='text-center'> <Col sm={12} className="text-center">
<h1 id='SendTokens'> <h1 id="SendTokens">
<FontAwesomeIcon <FontAwesomeIcon
className='title-icon' className="title-icon"
size='xs' size="xs"
icon='paper-plane' icon="paper-plane"
/> />
<span>Send</span> <span>Send</span>
</h1> </h1>
<Box className='border-none'> <Box className="border-none">
<Text <Text
id='addressToSend' id="addressToSend"
name='address' name="address"
placeholder='Enter simpleledger address to send' placeholder="Enter simpleledger address to send"
label='SLP Address' label="SLP Address"
labelPosition='above' labelPosition="above"
onChange={_this.handleUpdate} onChange={_this.handleUpdate}
className='title-icon' className="title-icon"
buttonRight={ buttonRight={
<Button icon='fa-qrcode' onClick={_this.handleModal} /> <Button icon="fa-qrcode" onClick={_this.handleModal} />
} }
/> />
<Text <Text
id='amountToSend' id="amountToSend"
name='amountSat' name="amountSat"
placeholder='Enter amount to send' placeholder="Enter amount to send"
label='Amount' label="Amount"
value={_this.state.amountSat} value={_this.state.amountSat}
labelPosition='above' labelPosition="above"
onChange={_this.handleUpdate} onChange={_this.handleUpdate}
/> />
<Row className='token-botton-container'> <Row className="token-botton-container">
<Col xs={12} sm={4}> <Col xs={12} sm={4}>
<Button <Button
text='Send' text="Send"
type='primary' type="primary"
className='btn-lg btn-send-token mr-1 ml-1 mt-1' className="btn-lg btn-send-token mr-1 ml-1 mt-1"
onClick={_this.handleSend} onClick={_this.handleSend}
/> />
</Col> </Col>
<Col xs={12} sm={4}> <Col xs={12} sm={4}>
<Button <Button
text='Send Max' text="Send Max"
type='primary' type="primary"
className='btn-lg btn-send-token mr-1 ml-1 mt-1' className="btn-lg btn-send-token mr-1 ml-1 mt-1"
onClick={_this.handleSendMax} onClick={_this.handleSendMax}
/> />
</Col> </Col>
<Col xs={12} sm={4}> <Col xs={12} sm={4}>
<Button <Button
text='Close' text="Close"
type='primary' type="primary"
className='btn-lg btn-send-token mr-1 ml-1 mt-1' className="btn-lg btn-send-token mr-1 ml-1 mt-1"
onClick={_this.props.handleBack} onClick={_this.props.handleBack}
/> />
</Col> </Col>
</Row> </Row>
</Box> </Box>
</Col> </Col>
<Col sm={12} className='text-center'> <Col sm={12} className="text-center">
{_this.state.errMsg && ( {_this.state.errMsg && (
<p className='error-color'>{_this.state.errMsg}</p> <p className="error-color">{_this.state.errMsg}</p>
)} )}
{/* {_this.state.txId && ( {/* {_this.state.txId && (
<p className=''> <p className=''>
@@ -216,12 +218,23 @@ class SendTokens extends React.Component {
const result = await bchWalletLib.sendTokens(receiver, 5.0) const result = await bchWalletLib.sendTokens(receiver, 5.0)
// console.log('result: ', result) // console.log('result: ', result)
_this.setState({ if (siteConfig.interface === 'consumer-api') {
txId: result, _this.setState({
inFetch: false txId: result.txid,
}) inFetch: false
})
_this.props.setTxId(result) /* Set the transaction ID in Tokens state */ // Set the transaction ID in Tokens state
_this.props.setTxId(result.txid)
} else {
_this.setState({
txId: result,
inFetch: false
})
// Set the transaction ID in Tokens state
_this.props.setTxId(result)
}
_this.resetValues() _this.resetValues()
@@ -338,9 +351,9 @@ class SendTokens extends React.Component {
Rate limits exceeded, increase rate limits with a JWT token from Rate limits exceeded, increase rate limits with a JWT token from
<a <a
style={{ marginLeft: '5px' }} style={{ marginLeft: '5px' }}
target='_blank' target="_blank"
href='https://fullstack.cash' href="https://fullstack.cash"
rel='noopener noreferrer' rel="noopener noreferrer"
> >
FullStack.cash FullStack.cash
</a> </a>
+2 -1
View File
@@ -23,7 +23,8 @@ const config = {
// Interface used by minial-slp-wallet // Interface used by minial-slp-wallet
interface: 'consumer-api', interface: 'consumer-api',
restURL: 'https://free-bch.fullstack.cash/' restURL: 'https://free-bch.fullstack.cash'
// restURL: 'http://localhost:5005'
// interface: 'rest-api', // interface: 'rest-api',
// restURL: 'https://bchn.fullstack.cash/v5/' // restURL: 'https://bchn.fullstack.cash/v5/'
} }