Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Fixes unconfirmed flow in payments
Browse files Browse the repository at this point in the history
Resolves #11334

Auditors:

Test Plan:
  • Loading branch information
NejcZdovc committed Oct 9, 2017
1 parent eda2732 commit 94f4f5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1712,22 +1712,17 @@ const onWalletProperties = (state, body) => {
// unconfirmed amount
const unconfirmed = parseFloat(body.get('unconfirmed'))
if (unconfirmed > 0) {
const result = (unconfirmed / 1e8).toFixed(4)
if (ledgerState.getInfoProp(state, 'unconfirmed') === result) {
if (ledgerState.getInfoProp(state, 'unconfirmed') === unconfirmed) {
return state
}

state = ledgerState.setInfoProp(state, 'unconfirmed', result)
state = ledgerState.setInfoProp(state, 'unconfirmed', unconfirmed)
if (clientOptions.verboseP) {
console.log('\ngetBalance refreshes ledger info: ' + ledgerState.getInfoProp(state, 'unconfirmed'))
}
return state
}

if (ledgerState.getInfoProp(state, 'unconfirmed') === '0.0000') {
return state
}

if (clientOptions.verboseP) {
console.log('\nWalletProperties refreshes payment info')
}
Expand Down
4 changes: 2 additions & 2 deletions app/common/lib/ledgerUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ const walletStatus = (ledgerData) => {
status.id = 'statusOnError'
} else if (ledgerData.get('created')) {
const transactions = ledgerData.get('transactions')
const pendingFunds = Number(ledgerData.get('unconfirmed') || 0)
const pendingFunds = Number(ledgerData.get('unconfirmed') || 0).toFixed(2)

if (pendingFunds + Number(ledgerData.get('balance') || 0) <
0.9 * Number(ledgerData.get('bat') || 0)) {
status.id = 'insufficientFundsStatus'
} else if (pendingFunds > 0) {
status.id = 'pendingFundsStatus'
status.args = {funds: batToCurrencyString(pendingFunds, ledgerData)}
status.args = {funds: `${pendingFunds} BAT (${batToCurrencyString(pendingFunds, ledgerData)})`}
} else if (transactions && transactions.size > 0) {
status.id = 'defaultWalletStatus'
} else {
Expand Down

0 comments on commit 94f4f5c

Please sign in to comment.