Browse Source

Remove some non-null assertions

master
Jared 1 year ago
parent
commit
990b5c7d54
1 changed files with 8 additions and 7 deletions
  1. +8
    -7
      src/views/FundView.vue

+ 8
- 7
src/views/FundView.vue View File

@@ -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;


Loading…
Cancel
Save