Merge pull request 'fix: loadActivePositionData has no error handling — silent failure on RPC error (#377)' (#423) from fix/issue-377 into master

This commit is contained in:
johba 2026-03-03 03:51:05 +01:00
commit 007a315f4f

View file

@ -35,7 +35,11 @@
</div>
</template>
<div class="collapsed-body">
<div class="profit-stats-wrapper">
<div v-if="error" class="collapsed-body--error">
<span>{{ error }}</span>
<FButton size="tiny" outlined @click="loadActivePositionData">Retry</FButton>
</div>
<div v-if="!error || taxPaidGes !== undefined" class="profit-stats-wrapper">
<div class="profit-stats-item">
<div><b>Tax Paid</b></div>
<div>{{ taxPaidGes ?? '...' }} $KRK</div>
@ -46,7 +50,7 @@
</div>
<div class="profit-stats-item profit-stats-total">
<div><b>Total</b></div>
<div>{{ total.toFixed(5) }} $KRK</div>
<div>{{ taxPaidGes !== undefined && profit !== undefined ? total.toFixed(5) : '...' }} $KRK</div>
</div>
</div>
</div>
@ -117,6 +121,7 @@ const taxDue = ref<bigint>(0n);
const taxPaidGes = ref<number>();
const profit = ref<number>();
const loading = ref<boolean>(false);
const error = ref<string | null>(null);
const tag = computed(() => {
// Compare by index instead of decimal to avoid floating-point issues
@ -214,14 +219,24 @@ async function unstakePosition() {
}
async function loadActivePositionData() {
//loadTaxDue
taxDue.value = await getTaxDue(props.id);
taxPaidGes.value = weiToNumber(taxDue.value + props.position.taxPaid);
loading.value = true;
error.value = null;
try {
//loadTaxDue
taxDue.value = await getTaxDue(props.id);
taxPaidGes.value = weiToNumber(taxDue.value + props.position.taxPaid);
//loadTotalSupply
//loadTotalSupply
// Calculate issuance earned using kraiken-lib profit calculation
profit.value = calculateActivePositionProfit(props.position.totalSupplyInit, statCollection.kraikenTotalSupply, props.position.share);
// Calculate issuance earned using kraiken-lib profit calculation
profit.value = calculateActivePositionProfit(props.position.totalSupplyInit, statCollection.kraikenTotalSupply, props.position.share);
} catch (err) {
// eslint-disable-next-line no-console
console.error('Failed to load active position data:', err);
error.value = 'Failed to load position data.';
} finally {
loading.value = false;
}
}
onMounted(() => {
@ -317,6 +332,14 @@ onMounted(() => {
&.profit-stats-total
border-top: 2px solid var(--color-font)
padding-top: 2px
.collapsed-body--error
display: flex
flex-wrap: wrap
align-items: center
gap: 8px
color: #f87171
font-size: 13px
margin-bottom: 8px
.collapsed-body--actions
.collapse-menu-open
display: flex