2025-10-21 15:11:46 +07:00
|
|
|
<script setup lang="ts">
|
2025-11-07 18:27:37 +07:00
|
|
|
import { ref, computed, onMounted } from 'vue'
|
|
|
|
|
import { Table, message } from 'ant-design-vue'
|
2025-10-24 22:49:46 +07:00
|
|
|
import { useNeptuneWallet } from '@/composables/useNeptuneWallet'
|
2025-11-07 18:27:37 +07:00
|
|
|
import { useNeptuneStore } from '@/stores/neptuneStore'
|
|
|
|
|
import { CardBaseScrollable, SpinnerCommon } from '@/components'
|
|
|
|
|
import { PER_PAGE } from '@/utils'
|
|
|
|
|
import { columns } from '../utils'
|
2025-10-24 22:49:46 +07:00
|
|
|
|
|
|
|
|
const { getUtxos } = useNeptuneWallet()
|
2025-11-07 18:27:37 +07:00
|
|
|
const neptuneStore = useNeptuneStore()
|
2025-10-21 15:11:46 +07:00
|
|
|
|
2025-11-07 18:27:37 +07:00
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
|
|
const utxosList = computed(() => [...(neptuneStore.getUtxos || []), ...Array.from({ length: 18 }, (_, i) => ({
|
|
|
|
|
additionRecord: `additionRecord${i}`,
|
|
|
|
|
amount: `${i}.00000000`,
|
|
|
|
|
blockHeight: `blockHeight${i}`,
|
|
|
|
|
utxoHash: `utxoHash${i}`,
|
|
|
|
|
}))])
|
|
|
|
|
|
|
|
|
|
const inUseUtxosCount = computed(() => (utxosList.value?.length ? utxosList.value.length : 0))
|
|
|
|
|
const inUseUtxosAmount = computed(() => {
|
|
|
|
|
if (!utxosList.value?.length) return '0.00000000'
|
|
|
|
|
|
|
|
|
|
const total = utxosList.value.reduce((total: number, utxo: any) => {
|
|
|
|
|
const amount = parseFloat(utxo.amount || utxo.value || 0)
|
|
|
|
|
return total + amount
|
|
|
|
|
}, 0)
|
|
|
|
|
|
|
|
|
|
return total.toFixed(8)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const loadUtxos = async () => {
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
const result = await getUtxos()
|
|
|
|
|
if (result.error) {
|
|
|
|
|
console.error(result.error.message)
|
|
|
|
|
message.error('Failed to load UTXOs')
|
|
|
|
|
loading.value = false
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
loading.value = false
|
|
|
|
|
} catch (err) {
|
|
|
|
|
message.error('Failed to load UTXOs')
|
|
|
|
|
console.error('Error loading UTXOs:', err)
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
loadUtxos()
|
|
|
|
|
})
|
2025-10-21 15:11:46 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-11-05 04:14:37 +07:00
|
|
|
<CardBaseScrollable class="content-card debug-card">
|
2025-10-21 15:11:46 +07:00
|
|
|
<div class="debug-header">
|
2025-11-07 18:27:37 +07:00
|
|
|
<h3 class="debug-title">IN USE UTXOS</h3>
|
2025-10-21 15:11:46 +07:00
|
|
|
<div class="debug-info">
|
2025-11-07 18:27:37 +07:00
|
|
|
<p><span>COUNT</span> {{ inUseUtxosCount }}</p>
|
|
|
|
|
<p><span>AMOUNT</span> {{ inUseUtxosAmount }} <strong>NPT</strong></p>
|
2025-10-21 15:11:46 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-11-07 18:27:37 +07:00
|
|
|
<div v-if="loading" class="loading-container">
|
|
|
|
|
<SpinnerCommon />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-else class="list-pagination">
|
|
|
|
|
<Table
|
|
|
|
|
:columns="columns"
|
|
|
|
|
:data-source="utxosList"
|
|
|
|
|
:scroll="{ x: 'max-content', y: '200px' }"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-11-05 04:14:37 +07:00
|
|
|
</CardBaseScrollable>
|
2025-10-21 15:11:46 +07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.debug-card {
|
|
|
|
|
.debug-header {
|
|
|
|
|
text-align: center;
|
|
|
|
|
margin-bottom: var(--spacing-2xl);
|
2025-11-07 18:27:37 +07:00
|
|
|
padding-bottom: var(--spacing-sm);
|
2025-10-21 15:11:46 +07:00
|
|
|
border-bottom: 2px solid var(--border-color);
|
|
|
|
|
|
|
|
|
|
.debug-title {
|
|
|
|
|
font-size: var(--font-2xl);
|
|
|
|
|
font-weight: var(--font-bold);
|
|
|
|
|
color: var(--text-primary);
|
2025-11-07 18:27:37 +07:00
|
|
|
margin-bottom: var(--spacing-xl);
|
2025-10-21 15:11:46 +07:00
|
|
|
letter-spacing: var(--tracking-wide);
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.debug-info {
|
|
|
|
|
display: flex;
|
2025-11-07 18:27:37 +07:00
|
|
|
justify-content: flex-start;
|
|
|
|
|
gap: var(--spacing-4xl);
|
2025-10-21 15:11:46 +07:00
|
|
|
|
|
|
|
|
p {
|
|
|
|
|
margin: 0;
|
|
|
|
|
font-size: var(--font-lg);
|
|
|
|
|
color: var(--text-secondary);
|
|
|
|
|
|
2025-11-07 18:27:37 +07:00
|
|
|
span {
|
|
|
|
|
color: var(--text-primary);
|
|
|
|
|
font-weight: var(--font-bold);
|
2025-10-21 15:11:46 +07:00
|
|
|
margin-right: var(--spacing-sm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-07 18:27:37 +07:00
|
|
|
|
|
|
|
|
.loading-container {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
min-height: 300px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.list-pagination {
|
|
|
|
|
:deep(.ant-table) {
|
|
|
|
|
background: transparent;
|
|
|
|
|
|
|
|
|
|
.ant-table-thead > tr > th {
|
|
|
|
|
background: var(--bg-light);
|
|
|
|
|
font-weight: var(--font-semibold);
|
|
|
|
|
color: var(--text-primary);
|
|
|
|
|
border-bottom: 2px solid var(--border-color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.ant-table-tbody > tr > td {
|
|
|
|
|
border-bottom: 1px solid var(--border-light);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.ant-table-tbody > tr:hover > td {
|
|
|
|
|
background: var(--bg-hover);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(.ant-pagination) {
|
|
|
|
|
margin-top: var(--spacing-lg);
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-21 15:11:46 +07:00
|
|
|
}
|
|
|
|
|
</style>
|