Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Whirlpool
whirlpool-gui
Commits
01f65003
Commit
01f65003
authored
Jul 02, 2020
by
zeroleak
Browse files
add utxos refresh button
parent
c0ca4874
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
33 deletions
+41
-33
app/components/MixStatus/index.js
app/components/MixStatus/index.js
+1
-1
app/containers/App.js
app/containers/App.js
+11
-6
app/reducers/wallet.js
app/reducers/wallet.js
+1
-16
app/services/backendService.js
app/services/backendService.js
+9
-4
app/services/utils.js
app/services/utils.js
+7
-1
app/services/walletService.js
app/services/walletService.js
+12
-5
No files found.
app/components/MixStatus/index.js
View file @
01f65003
...
...
@@ -5,7 +5,7 @@
*/
import
React
from
'
react
'
;
import
{
ProgressBar
}
from
'
react-bootstrap
'
;
import
{
ProgressBar
}
from
'
react-bootstrap
'
;
import
mixService
from
'
../../services/mixService
'
;
import
utils
from
'
../../services/utils
'
;
import
*
as
Icon
from
'
react-feather
'
;
...
...
app/containers/App.js
View file @
01f65003
...
...
@@ -169,7 +169,12 @@ class App extends React.Component<Props> {
{
cliService
.
isLoggedIn
()
&&
walletService
.
isReady
()
&&
<
div
>
<
button
className
=
'
btn btn-sm btn-primary btn-deposit
'
onClick
=
{()
=>
modalService
.
openDeposit
()}
><
Icon
.
Plus
size
=
{
12
}
/> Deposit</
button
>
<
div
><
small
>
Balance
:
{
utils
.
toBtc
(
walletService
.
getBalanceDeposit
()
+
walletService
.
getBalancePremix
()
+
walletService
.
getBalancePostmix
(),
true
)}
<
/small></
div
>
<
div
>
<
small
>
Balance
:
{
utils
.
toBtc
(
walletService
.
getBalance
(),
true
)}
<
/small>{' '
}
<
small
className
=
'
text-muted
'
title
=
{
'
Refresh utxos (
'
+
utils
.
durationElapsed
(
walletService
.
getLastUpdate
())
+
'
ago)
'
}
>
<
a
href
=
'
#
'
onClick
=
{
e
=>
{
walletService
.
fetchState
(
true
);
e
.
preventDefault
()}}
><
Icon
.
RefreshCw
size
=
{
12
}
/> </
a
>
<
/small
>
<
/div
>
<
/div>
}
<
ul
className
=
"
nav flex-column
"
>
...
...
@@ -237,11 +242,11 @@ class App extends React.Component<Props> {
<
small
>
Fetching
wallet
...
<
/small
>
<
/div>
}
<
div
className
=
"
footerNav
"
>
<
div
>
{
cliService
.
isConnected
()
&&
<
small
>
{
cliService
.
getServerName
()}
<
/small>
}
{
cliService
.
isCliLocal
()
&&
<
small
>
{
cliLocalStatusIcon
}
standalone
<
/small>
}
<
/div
>
{
!
cliService
.
isCliLocal
()
&&
<
div
><
small
>
{
cliService
.
getCliUrl
()}
<
/small></
div
>
}
<
div
>
{
cliService
.
isConnected
()
&&
<
small
>
{
cliService
.
getServerName
()}
<
/small>
}
{
cliService
.
isCliLocal
()
&&
<
small
>
{
cliLocalStatusIcon
}
standalone
<
/small>
}
<
/div
>
{
!
cliService
.
isCliLocal
()
&&
<
div
><
small
>
{
cliService
.
getCliUrl
()}
<
/small></
div
>
}
<
/div
>
<
/div
>
<
Status
...
...
app/reducers/wallet.js
View file @
01f65003
...
...
@@ -3,22 +3,7 @@ import { WALLET_SET } from '../actions/walletActions';
import
type
{
Action
}
from
'
./types
'
;
import
produce
from
'
immer
'
;
const
initialState
=
{
/*wallet: {
deposit: {
utxos:[],
balance:0
},
premix: {
utxos:[],
balance:0
},
postmix: {
utxos:[],
balance:0
}
}*/
}
const
initialState
=
{}
const
reducer
=
produce
((
state
,
action
)
=>
{
const
payload
=
action
.
payload
...
...
app/services/backendService.js
View file @
01f65003
...
...
@@ -82,6 +82,11 @@ class BackendService {
this
.
fetchBackendAsJson
(
'
/rest/cli/logout
'
,
'
POST
'
)
,
'
cli.logout
'
)
},
restart
:
()
=>
{
return
this
.
withStatus
(
'
CLI
'
,
'
Restart
'
,
()
=>
this
.
fetchBackendAsJson
(
'
/rest/cli/restart
'
,
'
POST
'
)
,
'
cli.restart
'
)
},
getConfig
:
()
=>
{
return
this
.
withStatus
(
'
CLI
'
,
'
Fetch configuration
'
,
()
=>
this
.
fetchBackendAsJson
(
'
/rest/cli/config
'
,
'
GET
'
)
...
...
@@ -110,10 +115,10 @@ class BackendService {
};
wallet
=
{
fetchUtxos
:
()
=>
{
return
this
.
withStatus
(
'
Wallet
'
,
'
Fetc
h utxos
'
,
()
=>
this
.
fetchBackendAsJson
(
'
/rest/utxos
'
,
'
GET
'
)
,
'
wallet.fetchUtxos
'
,
tru
e
)
fetchUtxos
:
(
refresh
=
false
)
=>
{
return
this
.
withStatus
(
'
Wallet
'
,
'
Refres
h utxos
'
,
()
=>
this
.
fetchBackendAsJson
(
'
/rest/utxos
?refresh=
'
+
refresh
,
'
GET
'
)
,
'
wallet.fetchUtxos
'
,
fals
e
)
},
fetchDeposit
:
(
increment
)
=>
{
...
...
app/services/utils.js
View file @
01f65003
...
...
@@ -3,7 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import
*
as
Icons
from
'
@fortawesome/free-solid-svg-icons
'
;
import
*
as
React
from
'
react
'
;
import
{
shell
}
from
'
electron
'
;
import
LinkExternal
from
'
../components/Utils/LinkExternal
'
;
import
moment
from
'
moment
'
;
const
AMOUNT_PRECISION
=
4
const
BTC_TO_SAT
=
100000000
...
...
@@ -42,6 +42,7 @@ export const MIXABLE_STATUS = {
export
const
CLI_STATUS
=
{
NOT_INITIALIZED
:
'
NOT_INITIALIZED
'
,
NOT_READY
:
'
NOT_READY
'
,
STARTING
:
'
STARTING
'
,
READY
:
'
READY
'
}
...
...
@@ -238,6 +239,11 @@ class Utils {
}
return
str
.
substring
(
0
,
5
)
+
'
...
'
+
str
.
substring
(
len
-
3
)
}
durationElapsed
(
time
)
{
const
elapsed
=
new
Date
().
getTime
()
-
time
return
moment
.
duration
(
elapsed
).
humanize
()
}
}
const
utils
=
new
Utils
()
...
...
app/services/walletService.js
View file @
01f65003
import
ifNot
from
'
if-not-running
'
;
import
moment
from
'
moment
'
;
import
backendService
from
'
./backendService
'
;
import
utils
from
'
./utils
'
;
const
REFRESH_RATE
=
10000
;
class
WalletService
{
...
...
@@ -51,8 +51,15 @@ class WalletService {
if
(
!
utxo
.
lastActivityElapsed
)
{
return
undefined
}
const
fetchElapsed
=
new
Date
().
getTime
()
-
this
.
state
.
wallet
.
fetchTime
return
moment
.
duration
(
fetchElapsed
+
utxo
.
lastActivityElapsed
).
humanize
()
return
utils
.
durationElapsed
(
this
.
state
.
wallet
.
fetchTime
-
utxo
.
lastActivityElapsed
)
}
getBalance
()
{
return
this
.
state
.
wallet
.
balance
;
}
getLastUpdate
()
{
return
this
.
state
.
wallet
.
lastUpdate
;
}
getUtxosDeposit
()
{
...
...
@@ -91,10 +98,10 @@ class WalletService {
return
this
.
state
.
wallet
.
postmix
.
zpub
}
fetchState
()
{
fetchState
(
refresh
=
false
)
{
return
ifNot
.
run
(
'
walletService:fetchState
'
,
()
=>
{
// fetchState backend
return
backendService
.
wallet
.
fetchUtxos
().
then
(
wallet
=>
{
return
backendService
.
wallet
.
fetchUtxos
(
refresh
).
then
(
wallet
=>
{
wallet
.
fetchTime
=
new
Date
().
getTime
()
// set state
if
(
this
.
state
===
undefined
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment