From 990b5c7d547c59997cce124c983238672d2e88ee Mon Sep 17 00:00:00 2001 From: Jared Date: Sun, 29 Jan 2023 02:20:35 -0500 Subject: [PATCH] Remove some non-null assertions --- src/views/FundView.vue | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/views/FundView.vue b/src/views/FundView.vue index 2653ef8..b19a3e1 100644 --- a/src/views/FundView.vue +++ b/src/views/FundView.vue @@ -390,12 +390,13 @@ const calculateWalletChars = () => round(width.value / 114, 0); const hasInvalidValues = () => { if (!fund.value) throw new Error('Fund was not loaded!'); - return [pk, amount].every((v) => v.value !== undefined && v.value !== '') - && (amount.value!.isZero() - || amount.value! > amountAvailable.value - || amount.value!.lt(fund.value.fundInfo.minContribution) - || (acctBalance.value && amt.value!.gt(acctBalance.value)) - || unknownAcct.value); + if ([pk, amount].some((v) => v.value === undefined || v.value === '')) return false; + if (!pk.value || !amount.value) throw new Error('One or more validation values were undefined'); + return (amount.value.isZero() + || amount.value > amountAvailable.value + || amount.value.lt(fund.value.fundInfo.minContribution) + || (acctBalance.value && amount.value.gt(acctBalance.value)) + || unknownAcct.value); }; const invalidContributionForm = computed(() => hasInvalidValues()); @@ -526,7 +527,7 @@ const makeContribution = async () => { if (!loading.value.contribution && pk.value && amount.value && amount.value <= amountAvailable.value) { loading.value.contribution = true; - await contribute(sanitize(pk.value), amount.value!.toNumber(), fund.value.fundInfo.id); + await contribute(sanitize(pk.value), amount.value.toNumber(), fund.value.fundInfo.id); loading.value.contribution = false; pk.value = ''; amt.value = undefined;