Skip to content

Commit 03833a9

Browse files
committed
Update tx fee: ui updates
1 parent e406871 commit 03833a9

File tree

4 files changed

+42
-13
lines changed

4 files changed

+42
-13
lines changed

src/assets/scss/style.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ svg {
136136
}
137137
}
138138

139+
.btn.btn-icon.btn-sm {
140+
display: inline;
141+
142+
svg {
143+
height: 16px;
144+
margin: 2px 0 0 0;
145+
}
146+
147+
svg.btn-loading {
148+
height: 16px;
149+
}
150+
}
151+
139152
.icon-fill-primary {
140153
path {
141154
fill: $color-primary;

src/store/actions/performNextAction.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ async function withInterval (func) {
3131
async function hasSwapExpired ({ getters }, { network, walletId, order }) {
3232
const fromClient = getters.client(network, walletId, order.from)
3333
try {
34-
const latestBlock = await fromClient.chain.getBlockByNumber(await fromClient.chain.getBlockHeight())
34+
const blockNumber = await fromClient.chain.getBlockHeight()
35+
const latestBlock = await fromClient.chain.getBlockByNumber(blockNumber)
3536
return latestBlock.timestamp > order.swapExpiration
3637
} catch (e) {
3738
console.warn(e)

src/store/actions/updateTransactionFee.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export const updateTransactionFee = async ({ dispatch, commit, getters }, { netw
1515
const lock = await dispatch('getLockForAsset', { order, network, walletId, asset })
1616
try {
1717
newTx = await client.chain.updateTransactionFee(oldTx, newFee)
18+
} catch (e) {
19+
console.warn(e)
20+
throw e
1821
} finally {
1922
unlockAsset(lock)
2023
}

src/views/TransactionDetails.vue

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,13 @@
7070
<a href="javascript:void(0)" @click="newFeePrice = feeSelectorFees.average.fee">Average: {{ feeSelectorFees.average.fee }}</a>
7171
<a href="javascript:void(0)" @click="newFeePrice = feeSelectorFees.fast.fee">Fast: {{ feeSelectorFees.fast.fee }}</a>
7272
</div>
73-
<button class="btn btn-sm btn-outline-primary" @click="closeFeeSelector()">Cancel</button>
74-
<button class="btn btn-sm btn-primary" @click="updateFee(step.tx.asset, step.tx.hash)">Update</button>
73+
<div>
74+
<button class="btn btn-sm btn-outline-primary" @click="closeFeeSelector()">Cancel</button>
75+
<button class="btn btn-sm btn-primary btn-icon" :disabled="feeSelectorLoading" @click="updateFee(step.tx.asset, step.tx.hash)">
76+
<SpinnerIcon class="btn-loading" v-if="feeSelectorLoading" />
77+
<template v-else>Update</template>
78+
</button>
79+
</div>
7580
</div>
7681
<a v-else href="javascript:void(0)" @click="openFeeSelector(step)">Speed up</a>
7782
</template>
@@ -266,6 +271,7 @@ export default {
266271
secretHidden: true,
267272
timeline: [],
268273
showFeeSelector: false,
274+
feeSelectorLoading: false,
269275
feeSelectorAsset: null,
270276
newFeePrice: null
271277
}
@@ -329,7 +335,7 @@ export default {
329335
return step.side === 'left' && (!step.tx.confirmations || step.tx.confirmations === 0)
330336
},
331337
feeSelectorEnabled (step) {
332-
return this.feeSelectorAsset === step.tx.asset && this.showFeeSelector
338+
return this.canUpdateFee(step) && this.feeSelectorAsset === step.tx.asset && this.showFeeSelector
333339
},
334340
openFeeSelector (step) {
335341
this.showFeeSelector = true
@@ -393,15 +399,20 @@ export default {
393399
this.timeline = timeline
394400
},
395401
async updateFee (asset, hash) {
396-
await this.updateTransactionFee({
397-
network: this.activeNetwork,
398-
walletId: this.activeWalletId,
399-
asset,
400-
id: this.item.id,
401-
hash,
402-
newFee: this.newFeePrice
403-
})
404-
this.showFeeSelector = false
402+
this.feeSelectorLoading = true
403+
try {
404+
await this.updateTransactionFee({
405+
network: this.activeNetwork,
406+
walletId: this.activeWalletId,
407+
asset,
408+
id: this.item.id,
409+
hash,
410+
newFee: this.newFeePrice
411+
})
412+
} finally {
413+
this.feeSelectorLoading = false
414+
this.showFeeSelector = false
415+
}
405416
}
406417
},
407418
created () {
@@ -577,6 +588,7 @@ export default {
577588
578589
.btn-primary {
579590
margin-left: 10px;
591+
min-width: 60px;
580592
}
581593
582594
&_fees {

0 commit comments

Comments
 (0)