Skip to content

Commit

Permalink
Fix incoming transactions when sender has one private key (#223)
Browse files Browse the repository at this point in the history
* fix list of incoming transactions for one pk
* fix decline exchange
  • Loading branch information
Asmadek authored Aug 22, 2019
1 parent e7678e0 commit 23ea05d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 45 deletions.
32 changes: 13 additions & 19 deletions src/components/Settlements/SettlementsIncoming.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,25 +191,19 @@ export default {
},

onReject () {
this.openApprovalDialog({ requiredMinAmount: this.accountQuorum })
.then(privateKeys => {
if (!privateKeys) return

return this.rejectSettlement({
privateKeys,
settlementBatch: this.settlementForRejection.from.batch
})
.then(() => {
this.$message.success('Rejected')
})
.catch(err => {
console.error(err)
this.$message.error('Failed to reject')
})
.finally(() => {
this.rejectionDialogVisible = false
this.getAllUnsignedTransactions()
})
return this.rejectSettlement({
settlementBatch: this.settlementForRejection.from.batch
})
.then(() => {
this.$message.success('Rejected')
})
.catch(err => {
console.error(err)
this.$message.error('Failed to reject')
})
.finally(() => {
this.rejectionDialogVisible = false
this.getAllUnsignedTransactions()
})
}
}
Expand Down
32 changes: 13 additions & 19 deletions src/components/Settlements/SettlementsOutgoing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,19 @@ export default {
]),

onReject () {
this.openApprovalDialog({ requiredMinAmount: this.accountQuorum })
.then(privateKeys => {
if (!privateKeys) return

return this.rejectSettlement({
privateKeys,
settlementBatch: this.settlementForRejection.from.batch
})
.then(() => {
this.$message.success('Rejected')
})
.catch(err => {
console.error(err)
this.$message.error('Failed to reject')
})
.finally(() => {
this.rejectionDialogVisible = false
this.getAllUnsignedTransactions()
})
return this.rejectSettlement({
settlementBatch: this.settlementForRejection.from.batch
})
.then(() => {
this.$message.success('Rejected')
})
.catch(err => {
console.error(err)
this.$message.error('Failed to reject')
})
.finally(() => {
this.rejectionDialogVisible = false
this.getAllUnsignedTransactions()
})
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/components/Transactions/TransactionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="transaction_details">
<p>
{{ scope.row.from }} transfered {{ scope.row.amount }}
{{ wallets.find(w => w.assetId = scope.row.assetId).asset }} to {{ scope.row.to }}
{{ availableAssets.find(w => w.assetId = scope.row.assetId).asset }} to {{ scope.row.to }}
</p>
<div>
<p>Was <el-tag>created</el-tag> at {{ formatDateLong(scope.row.date) }}</p>
Expand All @@ -45,7 +45,7 @@
>
<template slot-scope="scope">
{{ scope.row.from === 'you' ? '−' : '+' }}{{ Number(scope.row.amount) }}
{{ wallets.find(w => w.assetId === scope.row.assetId).asset }}
{{ availableAssets.find(w => w.assetId === scope.row.assetId).asset }}
</template>
</el-table-column>
<el-table-column
Expand Down Expand Up @@ -82,7 +82,7 @@
width="60"
>
<template slot-scope="scope">
{{ scope.row.signatures.length >= accountQuorum ? scope.row.signatures.length / 2 : scope.row.signatures.length }}
{{ scope.row.signatures.length > accountQuorum ? scope.row.signatures.length / 2 : scope.row.signatures.length }}
/
{{ accountQuorum }}
</template>
Expand Down Expand Up @@ -144,7 +144,7 @@
width="60"
>
<template slot-scope="scope">
{{ scope.row.signatures.length >= accountQuorum ? scope.row.signatures.length / 2 : scope.row.signatures.length }}
{{ scope.row.signatures.length > accountQuorum ? scope.row.signatures.length / 2 : scope.row.signatures.length }}
/
{{ accountQuorum }}
</template>
Expand Down Expand Up @@ -197,6 +197,7 @@ export default {
'pendingTransferTransactions',
'pendingSettingsTransactions',
'wallets',
'availableAssets',
'accountQuorum'
])
},
Expand Down
6 changes: 3 additions & 3 deletions src/store/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ const getters = {
return !Array.isArray(rawUnsignedTransactionsCopy) ? getSettlementsFrom(
rawUnsignedTransactionsCopy.toObject().transactionsList,
state.accountId
) : []
).filter(Boolean) : []
},

incomingSettlements (state) {
Expand All @@ -293,7 +293,7 @@ const getters = {
return (pair.from.txId % 2 === 1) && (pair.from.from === state.accountId)
})
.filter(pair => {
return pair.to.quorum === pair.to.signatures.length
return pair.to.signatures.length >= pair.to.quorum / 2
})
},

Expand Down Expand Up @@ -1241,7 +1241,7 @@ const actions = {
})
},

rejectSettlement ({ commit, state, getters }, { privateKeys, settlementBatch }) {
rejectSettlement ({ commit, state, getters }, { settlementBatch }) {
commit(types.REJECT_SETTLEMENT_REQUEST)
const batch = findBatchFromRaw(state.rawUnsignedTransactions, settlementBatch)
const fakePrivateKeys = [...new Array(21)].map(() => irohaUtil.generateKeypair().privateKey)
Expand Down

0 comments on commit 23ea05d

Please sign in to comment.