feat(gui): Refund swap in the background (#154)

Swaps will now be refunded as soon as the cancel timelock expires if the GUI is running but the swap dialog is not open.
This commit is contained in:
binarybaron 2024-11-14 14:20:22 +01:00 committed by GitHub
parent 4cf5cf719a
commit e46be4a9ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 210 additions and 27 deletions

View file

@ -5,6 +5,7 @@ import {
GetSwapInfoResponse,
TauriContextStatusEvent,
TauriTimelockChangeEvent,
BackgroundRefundState,
} from "models/tauriModel";
import { MoneroRecoveryResponse } from "../../models/rpcModel";
import { GetSwapInfoResponseExt } from "models/tauriModelExt";
@ -27,6 +28,10 @@ interface State {
// TODO: Reimplement this using Tauri
updateState: false;
};
backgroundRefund: {
swapId: string;
state: BackgroundRefundState;
} | null;
}
export interface RPCSlice {
@ -46,6 +51,7 @@ const initialState: RPCSlice = {
moneroWalletRpc: {
updateState: false,
},
backgroundRefund: null,
},
logs: [],
};
@ -109,6 +115,12 @@ export const rpcSlice = createSlice({
rpcResetMoneroRecoveryKeys(slice) {
slice.state.moneroRecovery = null;
},
rpcSetBackgroundRefundState(slice, action: PayloadAction<{ swap_id: string, state: BackgroundRefundState }>) {
slice.state.backgroundRefund = {
swapId: action.payload.swap_id,
state: action.payload.state,
};
},
},
});
@ -122,6 +134,7 @@ export const {
rpcSetSwapInfo,
rpcSetMoneroRecoveryKeys,
rpcResetMoneroRecoveryKeys,
rpcSetBackgroundRefundState,
timelockChangeEventReceived
} = rpcSlice.actions;