Merge pull request #106 from lbryio/fee-fix

fix: correctly show fees on tx's with no balance_delta or value (updates)
This commit is contained in:
Sean Yesmunt 2018-12-07 15:37:29 -05:00 committed by GitHub
commit 6953a29c2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

7
dist/bundle.js vendored
View file

@ -4573,14 +4573,17 @@ var selectTransactionItems = exports.selectTransactionItems = (0, _reselect.crea
items.push.apply(items, _toConsumableArray(append.map(function (item) { items.push.apply(items, _toConsumableArray(append.map(function (item) {
// value on transaction, amount on outpoint // value on transaction, amount on outpoint
// amount is always positive, but should match sign of value // amount is always positive, but should match sign of value
var amount = parseFloat(item.balance_delta ? item.balance_delta : item.value); var balanceDelta = parseFloat(item.balance_delta);
var value = parseFloat(item.value);
var amount = balanceDelta || value;
var fee = parseFloat(tx.fee);
return { return {
txid: txid, txid: txid,
timestamp: tx.timestamp, timestamp: tx.timestamp,
date: tx.timestamp ? new Date(Number(tx.timestamp) * 1000) : null, date: tx.timestamp ? new Date(Number(tx.timestamp) * 1000) : null,
amount: amount, amount: amount,
fee: amount < 0 ? -1 * tx.fee / append.length : 0, fee: fee,
claim_id: item.claim_id, claim_id: item.claim_id,
claim_name: item.claim_name, claim_name: item.claim_name,
type: item.type || TRANSACTIONS.SPEND, type: item.type || TRANSACTIONS.SPEND,

View file

@ -127,14 +127,17 @@ export const selectTransactionItems = createSelector(selectTransactionsById, (by
...append.map((item) => { ...append.map((item) => {
// value on transaction, amount on outpoint // value on transaction, amount on outpoint
// amount is always positive, but should match sign of value // amount is always positive, but should match sign of value
const amount = parseFloat(item.balance_delta ? item.balance_delta : item.value); const balanceDelta = parseFloat(item.balance_delta);
const value = parseFloat(item.value);
const amount = balanceDelta || value;
const fee = parseFloat(tx.fee);
return { return {
txid, txid,
timestamp: tx.timestamp, timestamp: tx.timestamp,
date: tx.timestamp ? new Date(Number(tx.timestamp) * 1000) : null, date: tx.timestamp ? new Date(Number(tx.timestamp) * 1000) : null,
amount, amount,
fee: amount < 0 ? -1 * tx.fee / append.length : 0, fee,
claim_id: item.claim_id, claim_id: item.claim_id,
claim_name: item.claim_name, claim_name: item.claim_name,
type: item.type || TRANSACTIONS.SPEND, type: item.type || TRANSACTIONS.SPEND,