diff --git a/backend/src/modules/bitcoinWallet/services/BitcoinWalletAdminService.spec.ts b/backend/src/modules/bitcoinWallet/services/BitcoinWalletAdminService.spec.ts index f512062..755d764 100644 --- a/backend/src/modules/bitcoinWallet/services/BitcoinWalletAdminService.spec.ts +++ b/backend/src/modules/bitcoinWallet/services/BitcoinWalletAdminService.spec.ts @@ -1,6 +1,6 @@ import { ServiceUnavailableException } from '@nestjs/common'; import type { ConfigService } from '@nestjs/config'; -import { BitcoinWalletSyncStatus } from '../types/BitcoinWalletSyncStatus'; +import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus'; import type { ElectrumWalletRpcClient } from './ElectrumWalletRpcClient'; import { BitcoinWalletAdminService } from './BitcoinWalletAdminService'; @@ -51,7 +51,7 @@ describe('BitcoinWalletAdminService', () => { rpcVersion: '4.8.1', blockHeight: 900_000, serverHeight: 900_000, - syncStatus: BitcoinWalletSyncStatus.Synced, + syncStatus: WalletSyncStatus.Synced, balanceBtc: '0.00150000', confirmedBalanceBtc: '0.00150000' }) @@ -63,7 +63,7 @@ describe('BitcoinWalletAdminService', () => { const status = await service.getStatus(); - expect(status.syncStatus).toBe(BitcoinWalletSyncStatus.Syncing); + expect(status.syncStatus).toBe(WalletSyncStatus.Syncing); }); it('throws when RPC calls fail', async () => { diff --git a/backend/src/modules/bitcoinWallet/services/BitcoinWalletAdminService.ts b/backend/src/modules/bitcoinWallet/services/BitcoinWalletAdminService.ts index a3dc27a..d3b31b6 100644 --- a/backend/src/modules/bitcoinWallet/services/BitcoinWalletAdminService.ts +++ b/backend/src/modules/bitcoinWallet/services/BitcoinWalletAdminService.ts @@ -2,7 +2,7 @@ import { Injectable, ServiceUnavailableException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { convertBtcAtomicToBtc } from '../../../utils/bitcoin/convertBtcAtomicToBtc'; import type { Config } from '../../../types/Config'; -import { BitcoinWalletSyncStatus } from '../types/BitcoinWalletSyncStatus'; +import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus'; import type { BitcoinWalletStatusView } from '../types/BitcoinWalletStatusView'; import { ElectrumWalletRpcClient } from './ElectrumWalletRpcClient'; @@ -47,15 +47,15 @@ export class BitcoinWalletAdminService { isSynchronized: boolean, blockHeight: number | null, serverHeight: number | null - ): BitcoinWalletSyncStatus { + ): WalletSyncStatus { if (isSynchronized) { - return BitcoinWalletSyncStatus.Synced; + return WalletSyncStatus.Synced; } if (blockHeight === null || serverHeight === null) { - return BitcoinWalletSyncStatus.Unknown; + return WalletSyncStatus.Unknown; } - return BitcoinWalletSyncStatus.Syncing; + return WalletSyncStatus.Syncing; } } diff --git a/backend/src/modules/bitcoinWallet/types/BitcoinWalletStatusView.ts b/backend/src/modules/bitcoinWallet/types/BitcoinWalletStatusView.ts index ca5d9af..a886581 100644 --- a/backend/src/modules/bitcoinWallet/types/BitcoinWalletStatusView.ts +++ b/backend/src/modules/bitcoinWallet/types/BitcoinWalletStatusView.ts @@ -1,12 +1,12 @@ import { ElectrumNetwork } from '../../../types/ElectrumNetwork'; -import { BitcoinWalletSyncStatus } from './BitcoinWalletSyncStatus'; +import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus'; export interface BitcoinWalletStatusView { network: ElectrumNetwork; rpcVersion: string; blockHeight: number | null; serverHeight: number | null; - syncStatus: BitcoinWalletSyncStatus; + syncStatus: WalletSyncStatus; balanceBtc: string; confirmedBalanceBtc: string; } diff --git a/backend/src/modules/bitcoinWallet/types/BitcoinWalletSyncStatus.ts b/backend/src/modules/bitcoinWallet/types/BitcoinWalletSyncStatus.ts deleted file mode 100644 index ae39d08..0000000 --- a/backend/src/modules/bitcoinWallet/types/BitcoinWalletSyncStatus.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum BitcoinWalletSyncStatus { - Synced = 'synced', - Syncing = 'syncing', - Unknown = 'unknown' -} diff --git a/backend/src/modules/moneroWallet/services/MoneroWalletAdminService.spec.ts b/backend/src/modules/moneroWallet/services/MoneroWalletAdminService.spec.ts index 75e7378..365dd14 100644 --- a/backend/src/modules/moneroWallet/services/MoneroWalletAdminService.spec.ts +++ b/backend/src/modules/moneroWallet/services/MoneroWalletAdminService.spec.ts @@ -2,7 +2,7 @@ import { BadRequestException, ServiceUnavailableException } from '@nestjs/common import type { ConfigService } from '@nestjs/config'; import axios from 'axios'; import type { AuthService } from '../../auth/services/AuthService'; -import { MoneroWalletSyncStatus } from '../types/MoneroWalletSyncStatus'; +import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus'; import type { MoneroWalletRpcClient } from './MoneroWalletRpcClient'; import { MoneroWalletAdminService } from './MoneroWalletAdminService'; @@ -76,7 +76,7 @@ describe('MoneroWalletAdminService', () => { rpcVersion: '0.18.3.1', walletHeight: 3_000_000, daemonHeight: 3_000_000, - syncStatus: MoneroWalletSyncStatus.Synced, + syncStatus: WalletSyncStatus.Synced, balanceXmr: '2.00000000', unlockedBalanceXmr: '1.00000000' }) @@ -137,7 +137,7 @@ describe('MoneroWalletAdminService', () => { const status = await service.getStatus(); - expect(status.syncStatus).toBe(MoneroWalletSyncStatus.Unknown); + expect(status.syncStatus).toBe(WalletSyncStatus.Unknown); expect(status.daemonHeight).toBeNull(); }); @@ -149,7 +149,7 @@ describe('MoneroWalletAdminService', () => { const status = await service.getStatus(); - expect(status.syncStatus).toBe(MoneroWalletSyncStatus.Synced); + expect(status.syncStatus).toBe(WalletSyncStatus.Synced); }); it('throws when reveal seed RPC fails', async () => { diff --git a/backend/src/modules/moneroWallet/services/MoneroWalletAdminService.ts b/backend/src/modules/moneroWallet/services/MoneroWalletAdminService.ts index 4ebc2d1..b146367 100644 --- a/backend/src/modules/moneroWallet/services/MoneroWalletAdminService.ts +++ b/backend/src/modules/moneroWallet/services/MoneroWalletAdminService.ts @@ -7,7 +7,7 @@ import type { Config } from '../../../types/Config'; import type { MoneroDaemonGetInfoResult } from '../types/MoneroDaemonGetInfoResult'; import type { MoneroWalletRevealSeedResult } from '../types/MoneroWalletRevealSeedResult'; import type { MoneroWalletStatusView } from '../types/MoneroWalletStatusView'; -import { MoneroWalletSyncStatus } from '../types/MoneroWalletSyncStatus'; +import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus'; import type { MoneroWalletWithdrawResult } from '../types/MoneroWalletWithdrawResult'; import { MoneroWalletRpcClient } from './MoneroWalletRpcClient'; @@ -72,7 +72,7 @@ export class MoneroWalletAdminService { throw new BadRequestException('No unlocked balance to withdraw.'); } - if (this.resolveSyncStatus(walletHeight, daemonHeight) !== MoneroWalletSyncStatus.Synced) { + if (this.resolveSyncStatus(walletHeight, daemonHeight) !== WalletSyncStatus.Synced) { throw new BadRequestException('Wallet is still syncing. Try again after sync completes.'); } @@ -125,11 +125,11 @@ export class MoneroWalletAdminService { } } - private resolveSyncStatus(walletHeight: number, daemonHeight: number | null): MoneroWalletSyncStatus { + private resolveSyncStatus(walletHeight: number, daemonHeight: number | null): WalletSyncStatus { if (daemonHeight === null) { - return MoneroWalletSyncStatus.Unknown; + return WalletSyncStatus.Unknown; } - return walletHeight >= daemonHeight - 1 ? MoneroWalletSyncStatus.Synced : MoneroWalletSyncStatus.Syncing; + return walletHeight >= daemonHeight - 1 ? WalletSyncStatus.Synced : WalletSyncStatus.Syncing; } } diff --git a/backend/src/modules/moneroWallet/types/MoneroWalletStatusView.ts b/backend/src/modules/moneroWallet/types/MoneroWalletStatusView.ts index cfc2254..6be381d 100644 --- a/backend/src/modules/moneroWallet/types/MoneroWalletStatusView.ts +++ b/backend/src/modules/moneroWallet/types/MoneroWalletStatusView.ts @@ -1,12 +1,12 @@ import { MoneroNetwork } from '../../../types/MoneroNetwork'; -import { MoneroWalletSyncStatus } from './MoneroWalletSyncStatus'; +import { WalletSyncStatus } from '../../../types/wallet/WalletSyncStatus'; export interface MoneroWalletStatusView { network: MoneroNetwork; rpcVersion: string; walletHeight: number; daemonHeight: number | null; - syncStatus: MoneroWalletSyncStatus; + syncStatus: WalletSyncStatus; balanceXmr: string; unlockedBalanceXmr: string; } diff --git a/backend/src/modules/moneroWallet/types/MoneroWalletSyncStatus.ts b/backend/src/types/wallet/WalletSyncStatus.ts similarity index 66% rename from backend/src/modules/moneroWallet/types/MoneroWalletSyncStatus.ts rename to backend/src/types/wallet/WalletSyncStatus.ts index c17d00a..1b164d8 100644 --- a/backend/src/modules/moneroWallet/types/MoneroWalletSyncStatus.ts +++ b/backend/src/types/wallet/WalletSyncStatus.ts @@ -1,4 +1,4 @@ -export enum MoneroWalletSyncStatus { +export enum WalletSyncStatus { Synced = 'synced', Syncing = 'syncing', Unknown = 'unknown'