mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-03 05:54:47 -05:00
feat(gui): Migrate to Tauri events
- Replace Electron IPC with Tauri invoke() for API calls - Implement TauriSwapProgressEvent for state management - Remove IpcInvokeButton, replace with PromiseInvokeButton - Update models: new tauriModel.ts, refactor rpcModel.ts - Simplify SwapSlice state, remove processRunning flag - Refactor SwapStatePage to use TauriSwapProgressEvent - Update HistoryRow and HistoryRowActions for new data structures - Remove unused Electron-specific components (e.g., RpcStatusAlert) - Update dependencies: React 18, Material-UI v4 to v5 - Implement typeshare for Rust/TypeScript type synchronization - Add BobStateName enum for more precise swap state tracking - Refactor utility functions for Tauri compatibility - Remove JSONStream and other Electron-specific dependencies
This commit is contained in:
parent
d54f5c6c77
commit
cf641bc8bb
77 changed files with 2484 additions and 2167 deletions
|
|
@ -1,21 +1,12 @@
|
|||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { ExtendedProviderStatus, ProviderStatus } from "models/apiModel";
|
||||
import { MoneroWalletRpcUpdateState } from "models/storeModel";
|
||||
import { GetSwapInfoResponse } from "models/tauriModel";
|
||||
import { CliLog } from "../../models/cliModel";
|
||||
import {
|
||||
GetSwapInfoResponse,
|
||||
MoneroRecoveryResponse,
|
||||
RpcProcessStateType,
|
||||
} from "../../models/rpcModel";
|
||||
import {
|
||||
CliLog,
|
||||
isCliLog,
|
||||
isCliLogDownloadingMoneroWalletRpc,
|
||||
isCliLogFailedToSyncMoneroWallet,
|
||||
isCliLogFinishedSyncingMoneroWallet,
|
||||
isCliLogStartedRpcServer,
|
||||
isCliLogStartedSyncingMoneroWallet,
|
||||
} from "../../models/cliModel";
|
||||
import { getLogsAndStringsFromRawFileString } from "utils/parseUtils";
|
||||
import { GetSwapInfoResponseExt } from "models/tauriModelExt";
|
||||
|
||||
type Process =
|
||||
| {
|
||||
|
|
@ -41,7 +32,7 @@ interface State {
|
|||
withdrawTxId: string | null;
|
||||
rendezvous_discovered_sellers: (ExtendedProviderStatus | ProviderStatus)[];
|
||||
swapInfos: {
|
||||
[swapId: string]: GetSwapInfoResponse;
|
||||
[swapId: string]: GetSwapInfoResponseExt;
|
||||
};
|
||||
moneroRecovery: {
|
||||
swapId: string;
|
||||
|
|
@ -51,7 +42,8 @@ interface State {
|
|||
isSyncing: boolean;
|
||||
};
|
||||
moneroWalletRpc: {
|
||||
updateState: false | MoneroWalletRpcUpdateState;
|
||||
// TODO: Reimplement this using Tauri
|
||||
updateState: false;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -85,44 +77,6 @@ export const rpcSlice = createSlice({
|
|||
name: "rpc",
|
||||
initialState,
|
||||
reducers: {
|
||||
rpcAddLogs(slice, action: PayloadAction<(CliLog | string)[]>) {
|
||||
if (
|
||||
slice.process.type === RpcProcessStateType.STARTED ||
|
||||
slice.process.type === RpcProcessStateType.LISTENING_FOR_CONNECTIONS ||
|
||||
slice.process.type === RpcProcessStateType.EXITED
|
||||
) {
|
||||
const logs = action.payload;
|
||||
slice.process.logs.push(...logs);
|
||||
|
||||
logs.filter(isCliLog).forEach((log) => {
|
||||
if (
|
||||
isCliLogStartedRpcServer(log) &&
|
||||
slice.process.type === RpcProcessStateType.STARTED
|
||||
) {
|
||||
slice.process = {
|
||||
type: RpcProcessStateType.LISTENING_FOR_CONNECTIONS,
|
||||
logs: slice.process.logs,
|
||||
address: log.fields.addr,
|
||||
};
|
||||
} else if (isCliLogDownloadingMoneroWalletRpc(log)) {
|
||||
slice.state.moneroWalletRpc.updateState = {
|
||||
progress: log.fields.progress,
|
||||
downloadUrl: log.fields.download_url,
|
||||
};
|
||||
|
||||
if (log.fields.progress === "100%") {
|
||||
slice.state.moneroWalletRpc.updateState = false;
|
||||
}
|
||||
} else if (isCliLogStartedSyncingMoneroWallet(log)) {
|
||||
slice.state.moneroWallet.isSyncing = true;
|
||||
} else if (isCliLogFinishedSyncingMoneroWallet(log)) {
|
||||
slice.state.moneroWallet.isSyncing = false;
|
||||
} else if (isCliLogFailedToSyncMoneroWallet(log)) {
|
||||
slice.state.moneroWallet.isSyncing = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
rpcInitiate(slice) {
|
||||
slice.process = {
|
||||
type: RpcProcessStateType.STARTED,
|
||||
|
|
@ -169,7 +123,8 @@ export const rpcSlice = createSlice({
|
|||
slice.state.withdrawTxId = null;
|
||||
},
|
||||
rpcSetSwapInfo(slice, action: PayloadAction<GetSwapInfoResponse>) {
|
||||
slice.state.swapInfos[action.payload.swap_id] = action.payload;
|
||||
slice.state.swapInfos[action.payload.swap_id] =
|
||||
action.payload as GetSwapInfoResponseExt;
|
||||
},
|
||||
rpcSetEndpointBusy(slice, action: PayloadAction<string>) {
|
||||
if (!slice.busyEndpoints.includes(action.payload)) {
|
||||
|
|
@ -202,7 +157,6 @@ export const rpcSlice = createSlice({
|
|||
|
||||
export const {
|
||||
rpcProcessExited,
|
||||
rpcAddLogs,
|
||||
rpcInitiate,
|
||||
rpcSetBalance,
|
||||
rpcSetWithdrawTxId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue