Fix build warnings

This commit is contained in:
Dennis Reimann 2021-11-02 17:58:25 +01:00
parent 0a704a911e
commit 1f736b5499
No known key found for this signature in database
GPG key ID: 5009E1797F03F8D0
7 changed files with 77 additions and 96 deletions

View file

@ -16,13 +16,11 @@ import { BrowserRouter as Router, Route ,Switch} from 'react-router-dom';
import { useGlobal } from 'reactn';
function App() {
const [walletList,setWalletList] = useState([])
const [makerStarted, setmakerStarted] = useGlobal("makerStarted");
const [walletName, setWalletName] = useGlobal("walletName");
const [coinjoinInProcess, setCoinjoinInProcess] = useGlobal("coinjoinInProcess");
const [currentStatusMessage, setCurrentStatusMessage] = useGlobal("currentStatusMessage");
const [, setCurrentStatusMessage] = useGlobal("currentStatusMessage");
const listWallets = async()=>{
const res = await fetch('/api/v1/wallet/all');
@ -43,10 +41,10 @@ function App() {
useInterval(() => {
const sessionClear = async()=>{
try{
const res = await fetch('/api/v1/session',{
method:"GET",
method:"GET",
});
const data = await res.json();
@ -77,30 +75,28 @@ function App() {
}
catch(e){
console.log("test")
alert("Lost connection to backend! Please restart the backend server.");
sessionStorage.clear();
}
}
sessionClear();
}, 8*1000);
useEffect(()=>{
const getWallets = async()=>{
const wallets = await listWallets();
console.log(wallets);
setWalletList(wallets);
}
getWallets();
},[])
const unlockWallet = async (name)=>{
let authData =JSON.parse(sessionStorage.getItem('auth'));
console.log(authData)
//if unlocking same wallet
@ -131,13 +127,13 @@ function App() {
token:token,
name:name
}))
}
catch(e){
alert("Something went wrong,please try again!")
}
}
}
@ -169,7 +165,7 @@ function App() {
catch(e){
alert("Error while locking.")
}
}
const listWalletInfo = async(name)=>{
@ -191,7 +187,7 @@ function App() {
wallet_info[mix_depths[2].account] = mix_depths[2].account_balance
wallet_info[mix_depths[3].account] = mix_depths[3].account_balance
wallet_info[mix_depths[4].account] = mix_depths[4].account_balance
return [data[0].walletinfo];
}
@ -211,7 +207,6 @@ function App() {
});
const data = await res.json();
console.log(data[0].walletinfo);
const wallet_name = name
const balance = data[0].walletinfo.total_balance;
const mix_depths = data[0].walletinfo.accounts;
const wallet_info={}
@ -257,7 +252,7 @@ function App() {
else{
alert(authData.name +" is in use! Please lock it first.")
}
}
@ -277,7 +272,7 @@ function App() {
"amount_sats": amountSats,
"destination": destination
}
),
})
const data = await res.json();
@ -287,8 +282,8 @@ function App() {
catch(e){
alert("Error while processing payment!")
}
}
else{
alert("please unlock wallet first")
@ -315,13 +310,13 @@ function App() {
'Authorization':token
},
body: JSON.stringify({
"mixdepth": mixdepth,
"amount": amount,
"counterparties": counterparties,
"destination":destination
}
),
})
const data = await res.json();
@ -336,12 +331,12 @@ function App() {
const startMakerService = async(txfee,cjfee_a,cjfee_r,ordertype,minsize)=>{
let authData =JSON.parse(sessionStorage.getItem('auth'));
if(!authData|| authData.login===false || authData.name===''){
alert("Please unlock a wallet first")
return;
}
let name = authData.name
let name = authData.name
try{
let token = "Bearer "+authData.token
const res = await fetch(`/api/v1/wallet/${name}/maker/start`,{
@ -356,10 +351,10 @@ function App() {
"ordertype":ordertype,
"minsize":minsize
}
),
});
const data = await res.json();
console.log(data);
}
@ -367,7 +362,7 @@ function App() {
catch(e){
alert("Error while starting service!")
}
}
const stopMakerService= async()=>{
@ -377,7 +372,7 @@ function App() {
return;
}
try{
let name = authData.name
let name = authData.name
let token = "Bearer "+authData.token
const res = await fetch(`/api/v1/wallet/${name}/maker/stop`,{
method:"GET",
@ -392,7 +387,7 @@ function App() {
catch(e){
alert("Error while stopping service!")
}
}
}
const getUTXOs = async()=>{
@ -423,7 +418,7 @@ function App() {
<div className="App">
<rb.Navbar sticky="top" collapseOnSelect expand="lg" bg="dark" variant="dark">
<rb.Container>
<rb.Navbar.Brand href='/'>Joinmarket</rb.Navbar.Brand>
<rb.Navbar.Toggle aria-controls="responsive-rb.Navbar-rb.Nav" />
@ -462,7 +457,7 @@ function App() {
<p></p>
<Switch>
<Route
path='/'
exact
@ -472,7 +467,7 @@ function App() {
</>
)}
/>
<Route
path='/showWallets'
exact
@ -490,7 +485,7 @@ function App() {
</>
)}
/>
<Route path='/create' exact render={(props) => (
<>
<CreateWallet onCreate={createWallet}></CreateWallet>
@ -516,14 +511,14 @@ function App() {
</>
)}
/>
</Switch>{" "}
</div>
</Router>
);
}
export default App;
export default App;

View file

@ -1,17 +1,16 @@
import React from 'react'
import { Button } from './Button'
import './displayMixdepth.css'
import { BrowserRouter as Router, Link, Route ,Switch} from 'react-router-dom';
import { Link } from 'react-router-dom';
import * as rb from 'react-bootstrap'
const DisplayMixdepth = ({walletInfo}) => {
const accounts = []
for (const account_info of walletInfo.accounts){
accounts.push(account_info)
}
return (
<div>
Total Balance: {walletInfo.total_balance} BTC
@ -19,12 +18,12 @@ const DisplayMixdepth = ({walletInfo}) => {
<rb.Button href="/maker">Maker Service</rb.Button>
<p></p>
{accounts.map((account, index) => (
<div key = {index}>
<rb.Accordion>
<rb.Accordion.Item eventKey={index}>
<rb.Accordion.Header className = "head">
<rb.Accordion.Header className = "head">
<div className = "links">
<rb.Container>
@ -46,14 +45,14 @@ const DisplayMixdepth = ({walletInfo}) => {
</rb.Col>
</rb.Row>
</rb.Container>
</div>
</rb.Accordion.Header>
<rb.Accordion.Body>
<rb.Accordion>
<rb.Accordion.Item eventKey="0">
<rb.Accordion.Header>External Addresses Balance: {accounts[index].branches[0].balance} BTC </rb.Accordion.Header>
<div className = "xpub">
Extended Pubkey : {accounts[index].branches[0].branch.split("\t").pop()}
@ -66,7 +65,7 @@ const DisplayMixdepth = ({walletInfo}) => {
<div className = "address_label">
<b>{accounts[index].branches[0].entries[i].labels}</b>
</div>
<rb.Accordion.Header>{accounts[index].branches[0].entries[i].address} {' '} </rb.Accordion.Header>
<rb.Accordion.Body>
<div className = "branch-body">
@ -78,7 +77,7 @@ const DisplayMixdepth = ({walletInfo}) => {
</div>
))}
</rb.Accordion.Body>
</rb.Accordion.Item>
</rb.Accordion.Item>
<rb.Accordion.Item eventKey="1">
<rb.Accordion.Header>Internal Addresses Balance: {accounts[index].branches[1].balance} BTC</rb.Accordion.Header>
<rb.Accordion.Body>

View file

@ -4,24 +4,17 @@ import { useState } from 'react'
import { useGlobal } from 'reactn';
const Maker = ({onStart,onStop}) => {
const [txFee,setTxFee] = useState('')
const [cjfeeAbs,setCjfeeabs] = useState('')
const [cjfeeRel,setCjfeerel] = useState('')
const [orderType,setOrdertype] = useState('')
const [minsize,setMinsize] = useState('')
const [makerStarted, setmakerStarted] = useGlobal("makerStarted");
const [submitVal,setSubmitVal] = useState('Start Maker Service')
const [makerStarted] = useGlobal("makerStarted");
const [setSubmitVal] = useState('Start Maker Service')
const history = useHistory();
const onSubmit = (e) => {
e.preventDefault()
if(makerStarted === false){
console.log('b')
@ -43,15 +36,15 @@ const Maker = ({onStart,onStop}) => {
}
let path = `/display`;
history.push(path);
}
return (
<div>
<h3>Maker Service</h3>
<form method="POST" onSubmit={onSubmit}>
<p></p>
{
makerStarted === false ?
@ -61,9 +54,9 @@ const Maker = ({onStart,onStop}) => {
</label>
:''
}
<p></p>
<input type="submit" value={makerStarted ==='true'?'Stop Maker Service':'Start Maker Service'} />
</form>

View file

@ -25,7 +25,7 @@ const Receive = ({onReceive}) => {
const data = await res.json();
console.log(data)
return (data[0].address);
}
useEffect(()=>{
@ -37,22 +37,22 @@ const Receive = ({onReceive}) => {
setNewAddress(temp)
return
}
getNewAddress(location.state.account_no);
},[])
}, [location.state.account_no])
const [temp_address, setTempAddress] = useState('')
const [amount, setAmount] = useState('')
const onSubmit = (e) => {
e.preventDefault()
if (!new_address) {
alert('Please add the address')
return
}
setTempAddress(new_address)
setTempAddress(new_address)
}
@ -68,24 +68,24 @@ const Receive = ({onReceive}) => {
<rb.Container className = "center">
<rb.Container fluid = "false" className = "form1">
<rb.Row>
<rb.Col className="label">
Address
</rb.Col>
<rb.Col>
<input type="text" name="address" value = {new_address } style = {{width: "415px"}} readOnly = {true} onChange={(e) => setNewAddress(e.target.value)}/>
</rb.Col>
</rb.Row>
<rb.Row className = "field">
<rb.Col className="label">
Amount(BTC)
</rb.Col>
<rb.Col>
<input type="text" name="amount_sats" value = {amount} style = {{width: "415px"}} onChange={(e) => setAmount(e.target.value)}/>
</rb.Col>
</rb.Row>
<rb.Row className = "btn-field">
<button className="btncr" type="submit" value="Submit" ><span>Get QR Code</span></button>

View file

@ -1,6 +1,4 @@
import React from 'react'
import { Button } from './Button'
import {Link} from 'react-router-dom'
import * as rb from 'react-bootstrap'
import './wallet.css'
const Wallet = ({name,onUnlock,onLock,onDisplay}) => {

View file

@ -1,34 +1,31 @@
import React from 'react'
import * as rb from 'react-bootstrap'
import './Homepage.css'
import { BrowserRouter as Router, Link, Route ,Switch} from 'react-router-dom';
import { Link } from 'react-router-dom';
const Homepage = () => {
return (
<>
<div className="showcase-container">
<h1 class="main-title" id="home">Joinmarket</h1>
<h1 className="main-title" id="home">Joinmarket</h1>
</div>
<rb.Container className = "container1">
<rb.Row>
<rb.Col className = "column">
<div class="text-center">
<div className="text-center">
<Link to="/create" className="btn btn-primary">Create Wallet</Link>
</div>
</rb.Col>
<rb.Col className = "column">
<Link to="/showWallets" className="btn btn-primary">Show Wallets</Link>
</rb.Col>
</rb.Row>
</rb.Container>
</>
)
}

View file

@ -1,7 +1,6 @@
import React, { useState, useEffect, useRef } from 'react';
const useInterval = (callback, delay) => {
import { useEffect, useRef } from 'react';
const useInterval = (callback, delay) => {
const savedCallback = useRef();
useEffect(() => {
@ -20,4 +19,4 @@ import React, { useState, useEffect, useRef } from 'react';
}, [delay]);
}
export default useInterval;
export default useInterval;