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