consolidate monero wallet sync status into shared WalletSyncStatus type.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<el-empty v-if="!loading && loadError" description="Failed to load wallet status" />
|
<el-empty v-if="!loading && loadError" description="Failed to load wallet status" />
|
||||||
|
|
||||||
<template v-if="!loading && !loadError && walletStatus">
|
<template v-if="!loading && !loadError && walletStatus">
|
||||||
<div v-if="walletStatus.syncStatus !== MoneroWalletSyncStatus.Synced" class="mb-16">
|
<div v-if="walletStatus.syncStatus !== WalletSyncStatus.Synced" class="mb-16">
|
||||||
<el-alert type="warning" :closable="false" show-icon title="Wallet is syncing. Please wait." />
|
<el-alert type="warning" :closable="false" show-icon title="Wallet is syncing. Please wait." />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@
|
|||||||
{{ walletStatus.daemonHeight ?? 'Unavailable' }}
|
{{ walletStatus.daemonHeight ?? 'Unavailable' }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="Sync">
|
<el-descriptions-item label="Sync">
|
||||||
<el-tag :type="resolveMoneroWalletSyncStatusTagType(walletStatus.syncStatus)" size="small">
|
<el-tag :type="resolveWalletSyncStatusTagType(walletStatus.syncStatus)" size="small">
|
||||||
{{ resolveMoneroWalletSyncStatusLabel(walletStatus.syncStatus) }}
|
{{ resolveWalletSyncStatusLabel(walletStatus.syncStatus) }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="Total balance">{{ walletStatus.balanceXmr }} XMR</el-descriptions-item>
|
<el-descriptions-item label="Total balance">{{ walletStatus.balanceXmr }} XMR</el-descriptions-item>
|
||||||
@@ -90,10 +90,12 @@
|
|||||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
|
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
|
||||||
import { computed, onBeforeMount, reactive, ref } from 'vue';
|
import { computed, onBeforeMount, reactive, ref } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { MoneroWalletSyncStatus } from '@/types/moneroWallet/MoneroWalletSyncStatus';
|
import { WalletSyncStatus } from '@/types/wallet/WalletSyncStatus';
|
||||||
import { useMoneroWalletStore } from '@/stores/moneroWallet';
|
import { useMoneroWalletStore } from '@/stores/moneroWallet';
|
||||||
import { isMoneroStandardAddress } from '@/utils/monero/isMoneroStandardAddress';
|
import { isMoneroStandardAddress } from '@/utils/monero/isMoneroStandardAddress';
|
||||||
import { resolveAxiosErrorMessage } from '@/utils/resolveAxiosErrorMessage';
|
import { resolveAxiosErrorMessage } from '@/utils/resolveAxiosErrorMessage';
|
||||||
|
import { resolveWalletSyncStatusLabel } from '@/utils/wallet/resolveWalletSyncStatusLabel';
|
||||||
|
import { resolveWalletSyncStatusTagType } from '@/utils/wallet/resolveWalletSyncStatusTagType';
|
||||||
|
|
||||||
const moneroWalletStore = useMoneroWalletStore();
|
const moneroWalletStore = useMoneroWalletStore();
|
||||||
|
|
||||||
@@ -125,7 +127,7 @@ const withdrawFormRules = computed<FormRules>(() => ({
|
|||||||
destinationAddress: [
|
destinationAddress: [
|
||||||
{
|
{
|
||||||
validator: (_rule, value, callback) => {
|
validator: (_rule, value, callback) => {
|
||||||
if (walletStatus.value?.syncStatus !== MoneroWalletSyncStatus.Synced) {
|
if (walletStatus.value?.syncStatus !== WalletSyncStatus.Synced) {
|
||||||
callback(new Error('Wait until the wallet finishes syncing before withdrawing'));
|
callback(new Error('Wait until the wallet finishes syncing before withdrawing'));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -287,26 +289,4 @@ const onRevealSeedClick = async (): Promise<void> => {
|
|||||||
const clearSeed = (): void => {
|
const clearSeed = (): void => {
|
||||||
revealedMnemonic.value = '';
|
revealedMnemonic.value = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
const resolveMoneroWalletSyncStatusLabel = (syncStatus: MoneroWalletSyncStatus): string => {
|
|
||||||
switch (syncStatus) {
|
|
||||||
case MoneroWalletSyncStatus.Synced:
|
|
||||||
return 'Synced';
|
|
||||||
case MoneroWalletSyncStatus.Syncing:
|
|
||||||
return 'Syncing';
|
|
||||||
default:
|
|
||||||
return 'Unknown';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const resolveMoneroWalletSyncStatusTagType = (syncStatus: MoneroWalletSyncStatus): 'success' | 'warning' | 'info' => {
|
|
||||||
switch (syncStatus) {
|
|
||||||
case MoneroWalletSyncStatus.Synced:
|
|
||||||
return 'success';
|
|
||||||
case MoneroWalletSyncStatus.Syncing:
|
|
||||||
return 'warning';
|
|
||||||
default:
|
|
||||||
return 'info';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import type { MoneroNetwork } from './MoneroNetwork';
|
import type { MoneroNetwork } from './MoneroNetwork';
|
||||||
import type { MoneroWalletSyncStatus } from './MoneroWalletSyncStatus';
|
import type { WalletSyncStatus } from '../wallet/WalletSyncStatus';
|
||||||
|
|
||||||
export interface MoneroWalletStatus {
|
export interface MoneroWalletStatus {
|
||||||
network: MoneroNetwork;
|
network: MoneroNetwork;
|
||||||
rpcVersion: string;
|
rpcVersion: string;
|
||||||
walletHeight: number;
|
walletHeight: number;
|
||||||
daemonHeight: number | null;
|
daemonHeight: number | null;
|
||||||
syncStatus: MoneroWalletSyncStatus;
|
syncStatus: WalletSyncStatus;
|
||||||
balanceXmr: string;
|
balanceXmr: string;
|
||||||
unlockedBalanceXmr: string;
|
unlockedBalanceXmr: string;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
export enum MoneroWalletSyncStatus {
|
export enum WalletSyncStatus {
|
||||||
Synced = 'synced',
|
Synced = 'synced',
|
||||||
Syncing = 'syncing',
|
Syncing = 'syncing',
|
||||||
Unknown = 'unknown'
|
Unknown = 'unknown'
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { WalletSyncStatus } from '@/types/wallet/WalletSyncStatus';
|
||||||
|
|
||||||
|
export const resolveWalletSyncStatusLabel = (syncStatus: WalletSyncStatus): string => {
|
||||||
|
switch (syncStatus) {
|
||||||
|
case WalletSyncStatus.Synced:
|
||||||
|
return 'Synced';
|
||||||
|
case WalletSyncStatus.Syncing:
|
||||||
|
return 'Syncing';
|
||||||
|
default:
|
||||||
|
return 'Unknown';
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { WalletSyncStatus } from '@/types/wallet/WalletSyncStatus';
|
||||||
|
|
||||||
|
export const resolveWalletSyncStatusTagType = (syncStatus: WalletSyncStatus): 'success' | 'warning' | 'info' => {
|
||||||
|
switch (syncStatus) {
|
||||||
|
case WalletSyncStatus.Synced:
|
||||||
|
return 'success';
|
||||||
|
case WalletSyncStatus.Syncing:
|
||||||
|
return 'warning';
|
||||||
|
default:
|
||||||
|
return 'info';
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user