diff --git a/crates/sage-wallet/src/database.rs b/crates/sage-wallet/src/database.rs index aa2dbb64..3ec1e07b 100644 --- a/crates/sage-wallet/src/database.rs +++ b/crates/sage-wallet/src/database.rs @@ -33,8 +33,8 @@ pub async fn upsert_coin( let start = Instant::now(); let is_p2 = tx.is_p2_puzzle_hash(coin_state.coin.puzzle_hash).await?; counters.is_p2 += start.elapsed(); - // If the coin is XCH, there's no reason to sync the puzzle. + // If the coin is XCH, there's no reason to sync the puzzle. let start = Instant::now(); tx.insert_coin_state(coin_state, is_p2, transaction_id) .await?; diff --git a/crates/sage-wallet/src/utils/submit.rs b/crates/sage-wallet/src/utils/submit.rs index 41e19877..d88078c0 100644 --- a/crates/sage-wallet/src/utils/submit.rs +++ b/crates/sage-wallet/src/utils/submit.rs @@ -21,10 +21,7 @@ pub async fn submit_to_peers( ) -> Result { let transaction_id = spend_bundle.name(); - info!( - "Broadcasting transaction id {}: {:?}", - transaction_id, spend_bundle - ); + info!("Checking transaction id {}", transaction_id); let mut mempool = false; let mut status = 0; @@ -60,37 +57,6 @@ pub async fn submit_transaction( spend_bundle: SpendBundle, genesis_challenge: Bytes32, ) -> Result { - let ack = match timeout( - Duration::from_secs(3), - peer.send_transaction(spend_bundle.clone()), - ) - .await - { - Ok(Ok(ack)) => ack, - Err(_timeout) => { - warn!("Send transaction timed out for {}", peer.socket_addr()); - return Ok(Status::Unknown); - } - Ok(Err(err)) => { - warn!( - "Send transaction failed for {}: {}", - peer.socket_addr(), - err - ); - return Ok(Status::Unknown); - } - }; - - info!( - "Transaction sent to {} with ack {:?}", - peer.socket_addr(), - ack - ); - - if ack.status == 1 { - return Ok(Status::Pending); - }; - let coin_ids: Vec = spend_bundle .coin_spends .iter() @@ -124,5 +90,38 @@ pub async fn submit_transaction( return Ok(Status::Failed(3, None)); } - Ok(Status::Failed(3, None)) + info!("Submitting transaction to {}", peer.socket_addr()); + + let ack = match timeout( + Duration::from_secs(3), + peer.send_transaction(spend_bundle.clone()), + ) + .await + { + Ok(Ok(ack)) => ack, + Err(_timeout) => { + warn!("Send transaction timed out for {}", peer.socket_addr()); + return Ok(Status::Unknown); + } + Ok(Err(err)) => { + warn!( + "Send transaction failed for {}: {}", + peer.socket_addr(), + err + ); + return Ok(Status::Unknown); + } + }; + + info!( + "Transaction response received from {} with ack {:?}", + peer.socket_addr(), + ack + ); + + if ack.status == 1 { + return Ok(Status::Pending); + }; + + Ok(Status::Failed(ack.status, ack.error)) } diff --git a/src/components/ConfirmationDialog.tsx b/src/components/ConfirmationDialog.tsx index 5415f258..bfe75ac6 100644 --- a/src/components/ConfirmationDialog.tsx +++ b/src/components/ConfirmationDialog.tsx @@ -265,6 +265,7 @@ export default function ConfirmationDialog({ if (!data) return reset(); onConfirm?.(); + reset(); })().finally(() => setPending(false)); }} disabled={pending} diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index be578c84..2df1e047 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -2,13 +2,13 @@ import { Cog, LogOut } from 'lucide-react'; import { PropsWithChildren, useMemo } from 'react'; import { Link, useNavigate } from 'react-router-dom'; +import { useInsets } from '@/contexts/SafeAreaContext'; import useInitialization from '@/hooks/useInitialization'; import { usePeers } from '@/hooks/usePeers'; import { useWallet } from '@/hooks/useWallet'; import icon from '@/icon.png'; import { logoutAndUpdateState, useWalletState } from '@/state'; import { Nav } from './Nav'; -import { useInsets } from '@/contexts/SafeAreaContext'; export default function Layout(props: PropsWithChildren) { const navigate = useNavigate(); diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index abdbd2b1..d61bb145 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -1,3 +1,4 @@ +import SafeAreaView from '@/components/SafeAreaView'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { @@ -35,7 +36,6 @@ import { useNavigate } from 'react-router-dom'; import { commands, KeyInfo, SecretKeyInfo } from '../bindings'; import Container from '../components/Container'; import { loginAndUpdateState } from '../state'; -import SafeAreaView from '@/components/SafeAreaView'; export default function Login() { const navigate = useNavigate(); @@ -66,7 +66,7 @@ export default function Login() { return ( -
+
{(keys?.length ?? 0) > 0 && ( <>