mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-04-20 16:06:00 -04:00
test
This commit is contained in:
parent
67530839e6
commit
df8189512a
23
src-gui/.gitignore
vendored
23
src-gui/.gitignore
vendored
@ -1,25 +1,2 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
.vite
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
@ -138,102 +138,6 @@ export interface SuspendCurrentSwapResponse {
|
||||
swap_id: string;
|
||||
}
|
||||
|
||||
export interface BuyXmrArgs {
|
||||
seller: string;
|
||||
bitcoin_change_address: string;
|
||||
monero_receive_address: string;
|
||||
}
|
||||
|
||||
export interface BuyXmrResponse {
|
||||
swap_id: string;
|
||||
quote: BidQuote;
|
||||
}
|
||||
|
||||
export interface ResumeSwapArgs {
|
||||
swap_id: string;
|
||||
}
|
||||
|
||||
export interface ResumeSwapResponse {
|
||||
result: string;
|
||||
}
|
||||
|
||||
export interface CancelAndRefundArgs {
|
||||
swap_id: string;
|
||||
}
|
||||
|
||||
export interface MoneroRecoveryArgs {
|
||||
swap_id: string;
|
||||
}
|
||||
|
||||
export interface WithdrawBtcArgs {
|
||||
amount?: number;
|
||||
address: string;
|
||||
}
|
||||
|
||||
export interface WithdrawBtcResponse {
|
||||
amount: number;
|
||||
txid: string;
|
||||
}
|
||||
|
||||
export interface ListSellersArgs {
|
||||
rendezvous_point: string;
|
||||
}
|
||||
|
||||
export interface StartDaemonArgs {
|
||||
server_address: string;
|
||||
}
|
||||
|
||||
export interface GetSwapInfoArgs {
|
||||
swap_id: string;
|
||||
}
|
||||
|
||||
export interface GetSwapInfoResponse {
|
||||
swap_id: string;
|
||||
seller: Seller;
|
||||
completed: boolean;
|
||||
start_date: string;
|
||||
state_name: string;
|
||||
xmr_amount: number;
|
||||
btc_amount: number;
|
||||
tx_lock_id: string;
|
||||
tx_cancel_fee: number;
|
||||
tx_refund_fee: number;
|
||||
tx_lock_fee: number;
|
||||
btc_refund_address: string;
|
||||
cancel_timelock: CancelTimelock;
|
||||
punish_timelock: PunishTimelock;
|
||||
timelock?: ExpiredTimelocks;
|
||||
}
|
||||
|
||||
export interface BalanceArgs {
|
||||
force_refresh: boolean;
|
||||
}
|
||||
|
||||
export interface BalanceResponse {
|
||||
balance: number;
|
||||
}
|
||||
|
||||
export interface GetHistoryArgs {
|
||||
}
|
||||
|
||||
export interface GetHistoryEntry {
|
||||
swap_id: string;
|
||||
state: string;
|
||||
}
|
||||
|
||||
export interface GetHistoryResponse {
|
||||
swaps: GetHistoryEntry[];
|
||||
}
|
||||
|
||||
export interface Seller {
|
||||
peer_id: string;
|
||||
addresses: string[];
|
||||
}
|
||||
|
||||
export interface SuspendCurrentSwapResponse {
|
||||
swap_id: string;
|
||||
}
|
||||
|
||||
export type TauriSwapProgressEvent =
|
||||
| { type: "Initiated", content?: undefined }
|
||||
| { type: "ReceivedQuote", content: BidQuote }
|
||||
@ -275,7 +179,9 @@ export type TauriSwapProgressEvent =
|
||||
| { type: "CooperativeRedeemRejected", content: {
|
||||
reason: string;
|
||||
}}
|
||||
| { type: "Released", content?: undefined };
|
||||
| { type: "Released", content: {
|
||||
error?: string;
|
||||
}};
|
||||
|
||||
export interface TauriSwapProgressEventWrapper {
|
||||
swap_id: string;
|
||||
|
@ -4,6 +4,11 @@ import {
|
||||
TauriSwapProgressEvent,
|
||||
} from "./tauriModel";
|
||||
|
||||
export type TauriSwapProgressEventType<T extends string> = Extract<
|
||||
TauriSwapProgressEvent,
|
||||
{ type: T }
|
||||
>;
|
||||
|
||||
export type TauriSwapProgressEventContent<
|
||||
T extends TauriSwapProgressEvent["type"],
|
||||
> = Extract<TauriSwapProgressEvent, { type: T }>["content"];
|
||||
|
@ -71,7 +71,13 @@ export default function SwapStatePage({
|
||||
case "CooperativeRedeemRejected":
|
||||
return <BitcoinPunishedPage />;
|
||||
case "Released":
|
||||
return <ProcessExitedPage prevState={state.prev} swapId={state.swapId} />;
|
||||
return (
|
||||
<ProcessExitedPage
|
||||
currState={state.curr}
|
||||
prevState={state.prev}
|
||||
swapId={state.swapId}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
// TODO: Use this when we have all states implemented, ensures we don't forget to implement a state
|
||||
// return exhaustiveGuard(state.curr.type);
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { Box, DialogContentText } from "@material-ui/core";
|
||||
import { SwapSpawnType } from "models/cliModel";
|
||||
import { SwapStateProcessExited } from "models/storeModel";
|
||||
import { TauriSwapProgressEventContent } from "models/tauriModelExt";
|
||||
import { useActiveSwapInfo, useAppSelector } from "store/hooks";
|
||||
import CliLogsBox from "../../../../other/RenderedCliLog";
|
||||
|
||||
export default function ProcessExitedAndNotDonePage({
|
||||
state,
|
||||
currState,
|
||||
}: {
|
||||
state: SwapStateProcessExited;
|
||||
currState: TauriSwapProgressEventContent<"Released">;
|
||||
}) {
|
||||
const swap = useActiveSwapInfo();
|
||||
const logs = useAppSelector((s) => s.swap.logs);
|
||||
@ -15,7 +15,7 @@ export default function ProcessExitedAndNotDonePage({
|
||||
|
||||
function getText() {
|
||||
const isCancelRefund = spawnType === SwapSpawnType.CANCEL_REFUND;
|
||||
const hasRpcError = state.rpcError != null;
|
||||
const hasRpcError = currState.error != null;
|
||||
const hasSwap = swap != null;
|
||||
|
||||
const messages = [];
|
||||
@ -58,11 +58,8 @@ export default function ProcessExitedAndNotDonePage({
|
||||
gap: "0.5rem",
|
||||
}}
|
||||
>
|
||||
{state.rpcError && (
|
||||
<CliLogsBox
|
||||
logs={[state.rpcError]}
|
||||
label="Error returned by the Swap Daemon"
|
||||
/>
|
||||
{currState.error != null && (
|
||||
<CliLogsBox logs={[currState.error]} label="Error" />
|
||||
)}
|
||||
<CliLogsBox logs={logs} label="Logs relevant to the swap" />
|
||||
</Box>
|
||||
|
@ -1,11 +1,15 @@
|
||||
import { TauriSwapProgressEvent } from "models/tauriModel";
|
||||
import { TauriSwapProgressEventType } from "models/tauriModelExt";
|
||||
import SwapStatePage from "../SwapStatePage";
|
||||
import ProcessExitedAndNotDonePage from "./ProcessExitedAndNotDonePage";
|
||||
|
||||
export default function ProcessExitedPage({
|
||||
prevState,
|
||||
currState,
|
||||
swapId,
|
||||
}: {
|
||||
prevState: TauriSwapProgressEvent | null;
|
||||
currState: TauriSwapProgressEventType<"Released">;
|
||||
swapId: string;
|
||||
}) {
|
||||
// If we have a previous state, we can show the user the last state of the swap
|
||||
@ -27,15 +31,5 @@ export default function ProcessExitedPage({
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: Display something useful here
|
||||
return (
|
||||
<>
|
||||
If the swap is not a "done" state (or we don't have a db state because the
|
||||
swap did complete the SwapSetup yet) we should tell the user and show logs
|
||||
Not implemented yet
|
||||
</>
|
||||
);
|
||||
|
||||
// If the swap is not a "done" state (or we don't have a db state because the swap did complete the SwapSetup yet) we should tell the user and show logs
|
||||
// return <ProcessExitedAndNotDonePage state={state} />;
|
||||
return <ProcessExitedAndNotDonePage currState={currState.content} />;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
use anyhow::Result;
|
||||
use bitcoin::Txid;
|
||||
use serde::Serialize;
|
||||
use std::sync::Arc;
|
||||
use tauri::{AppHandle, Emitter};
|
||||
use typeshare::typeshare;
|
||||
use uuid::Uuid;
|
||||
|
||||
@ -12,27 +14,15 @@ use crate::{monero, network::quote::BidQuote};
|
||||
static SWAP_PROGRESS_EVENT_NAME: &str = "swap-progress-update";
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TauriHandle(
|
||||
#[cfg(feature = "tauri")]
|
||||
#[cfg_attr(feature = "tauri", allow(unused))]
|
||||
std::sync::Arc<tauri::AppHandle>,
|
||||
);
|
||||
pub struct TauriHandle(Arc<AppHandle>);
|
||||
|
||||
impl TauriHandle {
|
||||
#[cfg(feature = "tauri")]
|
||||
pub fn new(tauri_handle: tauri::AppHandle) -> Self {
|
||||
Self(
|
||||
#[cfg(feature = "tauri")]
|
||||
std::sync::Arc::new(tauri_handle),
|
||||
)
|
||||
pub fn new(tauri_handle: AppHandle) -> Self {
|
||||
Self(Arc::new(tauri_handle))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn emit_tauri_event<S: Serialize + Clone>(&self, event: &str, payload: S) -> Result<()> {
|
||||
#[cfg(tauri)]
|
||||
self.0.emit(event, payload).map_err(|e| e.into())?;
|
||||
|
||||
Ok(())
|
||||
self.0.emit(event, payload).map_err(|e| e.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user