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" />
|
||||
|
||||
<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." />
|
||||
</div>
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
{{ walletStatus.daemonHeight ?? 'Unavailable' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="Sync">
|
||||
<el-tag :type="resolveMoneroWalletSyncStatusTagType(walletStatus.syncStatus)" size="small">
|
||||
{{ resolveMoneroWalletSyncStatusLabel(walletStatus.syncStatus) }}
|
||||
<el-tag :type="resolveWalletSyncStatusTagType(walletStatus.syncStatus)" size="small">
|
||||
{{ resolveWalletSyncStatusLabel(walletStatus.syncStatus) }}
|
||||
</el-tag>
|
||||
</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 { computed, onBeforeMount, reactive, ref } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { MoneroWalletSyncStatus } from '@/types/moneroWallet/MoneroWalletSyncStatus';
|
||||
import { WalletSyncStatus } from '@/types/wallet/WalletSyncStatus';
|
||||
import { useMoneroWalletStore } from '@/stores/moneroWallet';
|
||||
import { isMoneroStandardAddress } from '@/utils/monero/isMoneroStandardAddress';
|
||||
import { resolveAxiosErrorMessage } from '@/utils/resolveAxiosErrorMessage';
|
||||
import { resolveWalletSyncStatusLabel } from '@/utils/wallet/resolveWalletSyncStatusLabel';
|
||||
import { resolveWalletSyncStatusTagType } from '@/utils/wallet/resolveWalletSyncStatusTagType';
|
||||
|
||||
const moneroWalletStore = useMoneroWalletStore();
|
||||
|
||||
@@ -125,7 +127,7 @@ const withdrawFormRules = computed<FormRules>(() => ({
|
||||
destinationAddress: [
|
||||
{
|
||||
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'));
|
||||
|
||||
return;
|
||||
@@ -287,26 +289,4 @@ const onRevealSeedClick = async (): Promise<void> => {
|
||||
const clearSeed = (): void => {
|
||||
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>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { MoneroNetwork } from './MoneroNetwork';
|
||||
import type { MoneroWalletSyncStatus } from './MoneroWalletSyncStatus';
|
||||
import type { WalletSyncStatus } from '../wallet/WalletSyncStatus';
|
||||
|
||||
export interface MoneroWalletStatus {
|
||||
network: MoneroNetwork;
|
||||
rpcVersion: string;
|
||||
walletHeight: number;
|
||||
daemonHeight: number | null;
|
||||
syncStatus: MoneroWalletSyncStatus;
|
||||
syncStatus: WalletSyncStatus;
|
||||
balanceXmr: string;
|
||||
unlockedBalanceXmr: string;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
export enum MoneroWalletSyncStatus {
|
||||
export enum WalletSyncStatus {
|
||||
Synced = 'synced',
|
||||
Syncing = 'syncing',
|
||||
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