From 1f736b549936137d34eb428cffd3c097ae07975f Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Tue, 2 Nov 2021 17:58:25 +0100 Subject: [PATCH] Fix build warnings --- joinmarket/src/App.js | 77 +++++++++---------- joinmarket/src/components/DisplayMixdepth.jsx | 23 +++--- joinmarket/src/components/Maker.jsx | 27 +++---- joinmarket/src/components/Receive.jsx | 18 ++--- joinmarket/src/components/Wallet.jsx | 2 - joinmarket/src/components/homepage.jsx | 19 ++--- joinmarket/src/components/utils.jsx | 7 +- 7 files changed, 77 insertions(+), 96 deletions(-) diff --git a/joinmarket/src/App.js b/joinmarket/src/App.js index 9b61bae9..463f455a 100644 --- a/joinmarket/src/App.js +++ b/joinmarket/src/App.js @@ -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() {
- + Joinmarket @@ -462,7 +457,7 @@ function App() {

- + )} /> - + )} /> - + ( <> @@ -516,14 +511,14 @@ function App() { )} /> - + {" "} - +
- - + + ); } -export default App; \ No newline at end of file +export default App; diff --git a/joinmarket/src/components/DisplayMixdepth.jsx b/joinmarket/src/components/DisplayMixdepth.jsx index 4edc98d7..5251cda6 100644 --- a/joinmarket/src/components/DisplayMixdepth.jsx +++ b/joinmarket/src/components/DisplayMixdepth.jsx @@ -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 (
Total Balance: {walletInfo.total_balance} BTC @@ -19,12 +18,12 @@ const DisplayMixdepth = ({walletInfo}) => { Maker Service

{accounts.map((account, index) => ( - +
- + - +
@@ -46,14 +45,14 @@ const DisplayMixdepth = ({walletInfo}) => { - - + +
- + External Addresses Balance: {accounts[index].branches[0].balance} BTC
Extended Pubkey : {accounts[index].branches[0].branch.split("\t").pop()} @@ -66,7 +65,7 @@ const DisplayMixdepth = ({walletInfo}) => {
{accounts[index].branches[0].entries[i].labels}
- + {accounts[index].branches[0].entries[i].address} {' '}
@@ -78,7 +77,7 @@ const DisplayMixdepth = ({walletInfo}) => {
))}
- + Internal Addresses Balance: {accounts[index].branches[1].balance} BTC diff --git a/joinmarket/src/components/Maker.jsx b/joinmarket/src/components/Maker.jsx index 5ff54987..f0b2b4f4 100644 --- a/joinmarket/src/components/Maker.jsx +++ b/joinmarket/src/components/Maker.jsx @@ -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 (

Maker Service

- - + +

{ makerStarted === false ? @@ -61,9 +54,9 @@ const Maker = ({onStart,onStop}) => { :'' } - +

- +
diff --git a/joinmarket/src/components/Receive.jsx b/joinmarket/src/components/Receive.jsx index dc9247db..c12e1aa7 100644 --- a/joinmarket/src/components/Receive.jsx +++ b/joinmarket/src/components/Receive.jsx @@ -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}) => { - + Address setNewAddress(e.target.value)}/> - + - + Amount(BTC) setAmount(e.target.value)}/> - + diff --git a/joinmarket/src/components/Wallet.jsx b/joinmarket/src/components/Wallet.jsx index cb13d2fc..1bab6392 100644 --- a/joinmarket/src/components/Wallet.jsx +++ b/joinmarket/src/components/Wallet.jsx @@ -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}) => { diff --git a/joinmarket/src/components/homepage.jsx b/joinmarket/src/components/homepage.jsx index 05661323..55e0d383 100644 --- a/joinmarket/src/components/homepage.jsx +++ b/joinmarket/src/components/homepage.jsx @@ -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 ( <> - +
-

Joinmarket

- +

Joinmarket

- + - - -
+
Create Wallet
- + Show Wallets - + ) } diff --git a/joinmarket/src/components/utils.jsx b/joinmarket/src/components/utils.jsx index a1dd9861..661c2998 100644 --- a/joinmarket/src/components/utils.jsx +++ b/joinmarket/src/components/utils.jsx @@ -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; \ No newline at end of file +export default useInterval;