mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-03 05:54:47 -05:00
feat(tauri, gui): Send event on changes to details, timelocks and tx_lock confirmations (#100)
- Send event when new swap state is inserated into database. The event only has the `swap_id` attached. The frontend then sends a request to the `get_swap_info` command to retrieve the updated version - Send event when the Bitcoin lock transaction gets a new confirmation - A new `watcher` daemon runs contineously and sends an event when the timelock updated. The event has the the `swap_id` and the timelock attached - Display logs on `ProcessExitedPage` (if swap was stopped prematurely) - Rename `CliLogEmittedEvent` to `TauriLogEvent` - Apply env_filter to tracing terminal writer to silence logging from other crates - Add `.env.*` files in `src-gui` to `.gitingore` Closes #93 and #12
This commit is contained in:
parent
e6dc7ddcef
commit
8f33fe5b41
28 changed files with 429 additions and 208 deletions
|
|
@ -1,14 +1,17 @@
|
|||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { ExtendedProviderStatus, ProviderStatus } from "models/apiModel";
|
||||
import {
|
||||
CliLogEmittedEvent,
|
||||
TauriLogEvent,
|
||||
GetSwapInfoResponse,
|
||||
TauriContextStatusEvent,
|
||||
TauriDatabaseStateEvent,
|
||||
TauriTimelockChangeEvent,
|
||||
} from "models/tauriModel";
|
||||
import { MoneroRecoveryResponse } from "../../models/rpcModel";
|
||||
import { GetSwapInfoResponseExt } from "models/tauriModelExt";
|
||||
import { getLogsAndStringsFromRawFileString } from "utils/parseUtils";
|
||||
import { CliLog } from "models/cliModel";
|
||||
import logger from "utils/logger";
|
||||
|
||||
interface State {
|
||||
balance: number | null;
|
||||
|
|
@ -52,7 +55,7 @@ export const rpcSlice = createSlice({
|
|||
name: "rpc",
|
||||
initialState,
|
||||
reducers: {
|
||||
receivedCliLog(slice, action: PayloadAction<CliLogEmittedEvent>) {
|
||||
receivedCliLog(slice, action: PayloadAction<TauriLogEvent>) {
|
||||
const buffer = action.payload.buffer;
|
||||
const logs = getLogsAndStringsFromRawFileString(buffer);
|
||||
slice.logs = slice.logs.concat(logs);
|
||||
|
|
@ -63,6 +66,16 @@ export const rpcSlice = createSlice({
|
|||
) {
|
||||
slice.status = action.payload;
|
||||
},
|
||||
timelockChangeEventReceived(
|
||||
slice,
|
||||
action: PayloadAction<TauriTimelockChangeEvent>
|
||||
) {
|
||||
if (slice.state.swapInfos[action.payload.swap_id]) {
|
||||
slice.state.swapInfos[action.payload.swap_id].timelock = action.payload.timelock;
|
||||
} else {
|
||||
logger.warn(`Received timelock change event for unknown swap ${action.payload.swap_id}`);
|
||||
}
|
||||
},
|
||||
rpcSetBalance(slice, action: PayloadAction<number>) {
|
||||
slice.state.balance = action.payload;
|
||||
},
|
||||
|
|
@ -110,6 +123,7 @@ export const {
|
|||
rpcSetSwapInfo,
|
||||
rpcSetMoneroRecoveryKeys,
|
||||
rpcResetMoneroRecoveryKeys,
|
||||
timelockChangeEventReceived
|
||||
} = rpcSlice.actions;
|
||||
|
||||
export default rpcSlice.reducer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue