Skip to content

Commit 7d80044

Browse files
committed
Handle missing fees
1 parent 9f74713 commit 7d80044

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

src/views/SwapConfirm.vue

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
<div class="form-group">
2222
<label>Network Fees</label>
2323
<div v-for="(fee, asset) in totalFees" :key="asset">
24-
<strong>~ {{ fee }}</strong>&nbsp;<span class="text-muted">{{ asset }}</span>&nbsp;<span>(${{prettyFiatBalance(fee, fiatRates[asset])}})</span>
24+
<strong>
25+
<template v-if="fee">~ {{ fee }}</template>
26+
<template v-else>Unknown</template>
27+
</strong>&nbsp;
28+
<span class="text-muted">{{ asset }}</span>&nbsp;
29+
<span v-if="fee">(${{prettyFiatBalance(fee, fiatRates[asset])}})</span>
2530
</div>
2631
</div>
2732
</div>
@@ -75,19 +80,27 @@ export default {
7580
return format(add(new Date(), { hours: 6 }), 'h:mm a')
7681
},
7782
totalFees () {
78-
const fees = {}
79-
8083
const assetChain = getChainFromAsset(this.asset)
81-
const initiationFee = getTxFee(this.asset, TX_TYPES.SWAP_INITIATION, this.fee)
82-
fees[assetChain] = initiationFee
83-
8484
const toAssetChain = getChainFromAsset(this.toAsset)
85-
const claimFee = getTxFee(this.toAsset, TX_TYPES.SWAP_CLAIM, this.toFee)
86-
fees[toAssetChain] = toAssetChain in fees ? fees[toAssetChain].plus(claimFee) : claimFee
8785
88-
if (this.sendTo) {
89-
const sendFee = getTxFee(this.toAsset, TX_TYPES.SEND, this.toFee)
90-
fees[toAssetChain] = toAssetChain in fees ? fees[toAssetChain].plus(sendFee) : sendFee
86+
const fees = {
87+
[assetChain]: null,
88+
[toAssetChain]: null
89+
}
90+
91+
if (this.fee) {
92+
const initiationFee = getTxFee(this.asset, TX_TYPES.SWAP_INITIATION, this.fee)
93+
fees[assetChain] = initiationFee
94+
}
95+
96+
if (this.toFee) {
97+
const claimFee = getTxFee(this.toAsset, TX_TYPES.SWAP_CLAIM, this.toFee)
98+
fees[toAssetChain] = toAssetChain in fees ? fees[toAssetChain].plus(claimFee) : claimFee
99+
100+
if (this.sendTo) {
101+
const sendFee = getTxFee(this.toAsset, TX_TYPES.SEND, this.toFee)
102+
fees[toAssetChain] = toAssetChain in fees ? fees[toAssetChain].plus(sendFee) : sendFee
103+
}
91104
}
92105
93106
return fees

0 commit comments

Comments
 (0)