Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peng/357 fix double self tx #358

Merged
merged 6 commits into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/src/renderer/components/wallet/LiTransaction.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template lang='pug'>
.ni-li-tx.ni-li-tx-sent(v-if="sent" @click="() => devMode && viewTransaction()")
.tx-icon: i.material-icons remove_circle
mixin tx-container-sent
.tx-container
.tx-element.tx-coins
.tx-coin(v-for='coin in coinsSent')
Expand All @@ -9,6 +8,14 @@
.tx-element.tx-date(v-if="devMode") {{ date }}
.tx-element.tx-address {{ receiver }}

.ni-li-tx(v-if="sentSelf" @click="() => devMode && viewTransaction()")
.tx-icon: i.material-icons swap_horiz
+tx-container-sent

.ni-li-tx.ni-li-tx-sent(v-else-if="sent" @click="() => devMode && viewTransaction()")
.tx-icon: i.material-icons remove_circle
+tx-container-sent

.ni-li-tx.ni-li-tx-received(v-else @click="() => devMode && viewTransaction()")
.tx-icon: i.material-icons add_circle
.tx-container
Expand All @@ -27,6 +34,9 @@ export default {
name: 'ni-li-tx',
computed: {
// TODO: sum relevant inputs/outputs
sentSelf () {
return this.transactionValue.tx.inputs[0].sender === this.transactionValue.tx.outputs[0].receiver
},
sent () {
return this.transactionValue.tx.inputs[0].sender === this.address
},
Expand Down
5 changes: 3 additions & 2 deletions app/src/renderer/components/wallet/PageTransactions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ page(title='Transactions')

<script>
import { mapGetters } from 'vuex'
import { includes, orderBy } from 'lodash'
import { includes, orderBy, uniqBy } from 'lodash'
import Mousetrap from 'mousetrap'
import DataEmptySearch from 'common/NiDataEmptySearch'
import DataEmptyTx from 'common/NiDataEmptyTx'
Expand All @@ -43,7 +43,8 @@ export default {
computed: {
...mapGetters(['filters', 'transactions', 'wallet', 'config']),
orderedTransactions () {
return orderBy(this.transactions, [this.sort.property], [this.sort.order])
let list = orderBy(this.transactions, [this.sort.property], [this.sort.order])
return uniqBy(list, 'time') // filter out duplicate tx to self
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me, but I think this would squash all tx to yourself by block (which might be ok, as it's a rare case and blocks are proposed every 1s?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're right. That's not intended. Will fix.

Copy link
Contributor Author

@nylira nylira Jan 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into resolving this and I think we need to wait until transactions have uids before this can be correctly fixed. Any sort of uniqueness filtering is stymied by the fact that the use can send two self transactions with exactly the same amount of tokens in the same block. Made an issue for this in #366

},
filteredTransactions () {
let query = this.filters.transactions.search.query
Expand Down