From 7d800441276bc5777b7cfa44fbb531f2a4d50f4e Mon Sep 17 00:00:00 2001 From: monokh Date: Tue, 15 Sep 2020 09:46:21 +0100 Subject: [PATCH] Handle missing fees --- src/views/SwapConfirm.vue | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/views/SwapConfirm.vue b/src/views/SwapConfirm.vue index 6df1c3579..ba526d81b 100644 --- a/src/views/SwapConfirm.vue +++ b/src/views/SwapConfirm.vue @@ -21,7 +21,12 @@
- ~ {{ fee }} {{ asset }} (${{prettyFiatBalance(fee, fiatRates[asset])}}) + + + +   + {{ asset }}  + (${{prettyFiatBalance(fee, fiatRates[asset])}})
@@ -75,19 +80,27 @@ export default { return format(add(new Date(), { hours: 6 }), 'h:mm a') }, totalFees () { - const fees = {} - const assetChain = getChainFromAsset(this.asset) - const initiationFee = getTxFee(this.asset, TX_TYPES.SWAP_INITIATION, this.fee) - fees[assetChain] = initiationFee - const toAssetChain = getChainFromAsset(this.toAsset) - const claimFee = getTxFee(this.toAsset, TX_TYPES.SWAP_CLAIM, this.toFee) - fees[toAssetChain] = toAssetChain in fees ? fees[toAssetChain].plus(claimFee) : claimFee - if (this.sendTo) { - const sendFee = getTxFee(this.toAsset, TX_TYPES.SEND, this.toFee) - fees[toAssetChain] = toAssetChain in fees ? fees[toAssetChain].plus(sendFee) : sendFee + const fees = { + [assetChain]: null, + [toAssetChain]: null + } + + if (this.fee) { + const initiationFee = getTxFee(this.asset, TX_TYPES.SWAP_INITIATION, this.fee) + fees[assetChain] = initiationFee + } + + if (this.toFee) { + const claimFee = getTxFee(this.toAsset, TX_TYPES.SWAP_CLAIM, this.toFee) + fees[toAssetChain] = toAssetChain in fees ? fees[toAssetChain].plus(claimFee) : claimFee + + if (this.sendTo) { + const sendFee = getTxFee(this.toAsset, TX_TYPES.SEND, this.toFee) + fees[toAssetChain] = toAssetChain in fees ? fees[toAssetChain].plus(sendFee) : sendFee + } } return fees