From 6684568471bf4e9a0f6964c6197ef812a1694e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathe=CC=81o?= Date: Thu, 15 Apr 2021 14:14:12 +0200 Subject: [PATCH] =?UTF-8?q?SellUtils:=20Fix=20error=20=C2=AB=C2=A0.value?= =?UTF-8?q?=20of=20undefined=C2=A0=C2=BB=20for=20estimate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/swap/utils/SellUtils.ts | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/lib/swap/utils/SellUtils.ts b/src/lib/swap/utils/SellUtils.ts index f6989ba6e..cce34639b 100644 --- a/src/lib/swap/utils/SellUtils.ts +++ b/src/lib/swap/utils/SellUtils.ts @@ -20,7 +20,6 @@ const { activeSwap: swap } = useSwapsStore(); const { exchangeRates } = useFiatStore(); const { activeCurrency } = useAccountStore(); const { accountBalance: accountBtcBalance, accountUtxos } = useBtcAddressStore(); -const { estimate } = useSwapEstimate(); /** * Sell - Sell crypto related things @@ -46,17 +45,21 @@ export const oasisSellLimitExceeded = computed(() => { return deniedSettlementInfo.detail.reason === DeniedReason.LIMIT_EXCEEDED; }); -export const nimFeePerUnit = computed(() => - (estimate.value && estimate.value.from.asset === SwapAsset.NIM && estimate.value.from.feePerUnit) - || (assets.value && assets.value[SwapAsset.NIM].feePerUnit) - || 0, // Default zero fees for NIM -); +export const nimFeePerUnit = computed(() => { + const { estimate } = useSwapEstimate(); -export const btcFeePerUnit = computed(() => - (estimate.value && estimate.value.from.asset === SwapAsset.BTC && estimate.value.from.feePerUnit) - || (assets.value && assets.value[SwapAsset.BTC].feePerUnit) - || 1, -); + return (estimate.value && estimate.value.from.asset === SwapAsset.NIM && estimate.value.from.feePerUnit) + || (assets.value && assets.value[SwapAsset.NIM].feePerUnit) + || 0; // Default zero fees for NIM +}); + +export const btcFeePerUnit = computed(() => { + const { estimate } = useSwapEstimate(); + + return (estimate.value && estimate.value.from.asset === SwapAsset.BTC && estimate.value.from.feePerUnit) + || (assets.value && assets.value[SwapAsset.BTC].feePerUnit) + || 1; +}); // 48 extra weight units for BTC HTLC funding tx export const btcFeeForSendingAll = computed(() => @@ -118,5 +121,6 @@ export async function updateSellEstimate({ fiatAmount, cryptoAmount } } } // eslint-disable-line brace-style + const { estimate } = useSwapEstimate(); estimate.value = newEstimate; }