From 054a0dc6e121be79e836e9289500ebd2ea4c6a29 Mon Sep 17 00:00:00 2001 From: Stuyk Date: Tue, 30 Apr 2024 19:04:16 +0100 Subject: [PATCH] fix: deposit popup not launching #84 (#85) --- src/components/popups/ProposalDeposit.vue | 16 ++++++++++++---- src/components/proposals/ProposalWrapper.vue | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/components/popups/ProposalDeposit.vue b/src/components/popups/ProposalDeposit.vue index 82d9335..6c913b6 100644 --- a/src/components/popups/ProposalDeposit.vue +++ b/src/components/popups/ProposalDeposit.vue @@ -34,13 +34,21 @@ const depositAmount = ref(null); const cliDepositInput = ref(""); const depositDenomDecimals = computed(() => { - return chainConfig.currencies.filter((x) => x.coinMinimalDenom == props.depositDenom)[0].coinDecimals ?? 0; + const currencies = chainConfig.currencies.filter((x) => x.coinMinimalDenom == props.depositDenom); + if (currencies.length <= 0) { + return 0; + } + + return currencies[0].coinDecimals ?? 0; }); const depositDenomDisplay = computed(() => { - return ( - chainConfig.currencies.filter((x) => x.coinMinimalDenom == props.depositDenom)[0].coinDenom ?? props.depositDenom - ); + const currencies = chainConfig.currencies.filter((x) => x.coinMinimalDenom == props.depositDenom); + if (!currencies) { + return props.depositDenom; + } + + return currencies[0].coinDenom ?? props.depositDenom; }); const resetDeposit = () => (depositAmount.value = null); diff --git a/src/components/proposals/ProposalWrapper.vue b/src/components/proposals/ProposalWrapper.vue index 7eadcef..917326f 100644 --- a/src/components/proposals/ProposalWrapper.vue +++ b/src/components/proposals/ProposalWrapper.vue @@ -334,13 +334,21 @@ const expectedResult = computed(() => { }); const stakingDenomDisplay = computed(() => { - return ( - chainConfig.currencies.filter((x) => x.coinMinimalDenom == depositDenom.value)[0]?.coinDenom ?? depositDenom.value - ); + const currencies = chainConfig.currencies.filter((x) => x.coinMinimalDenom == depositDenom.value); + if (currencies.length <= 0) { + return depositDenom.value; + } + + return currencies[0].coinDenom ?? depositDenom.value; }); const stakingDenomDecimals = computed(() => { - return chainConfig.currencies.filter((x) => x.coinMinimalDenom == depositDenom.value)[0]?.coinDecimals ?? 0; + const currencies = chainConfig.currencies.filter((x) => x.coinMinimalDenom == depositDenom.value); + if (currencies.length <= 0) { + return 0; + } + + return currencies[0].coinDecimals ?? 0; }); function calculateWidthForTree(key: VoteTypes) {