adding confirmation message to rootstock swap

This commit is contained in:
Blake Kaufman
2025-09-04 17:02:43 -04:00
parent 9573b2726f
commit b1f57a68ad
6 changed files with 57 additions and 5 deletions
+2
View File
@@ -40,6 +40,7 @@ import {
} from './app/constants';
import {LiquidEventProvider} from './context-store/liquidEventContext';
import {
RootstockNavigationListener,
// EcashNavigationListener,
// LightningNavigationListener,
// LiquidNavigationListener,
@@ -398,6 +399,7 @@ function ResetStack(): JSX.Element | null {
{/* <StatusBar style={theme ? 'light' : 'dark'} translucent={true} /> */}
<HandleLNURLPayments />
<SparkNavigationListener />
<RootstockNavigationListener />
<ToastContainer />
<SparkConnectionManager />
{/* <EcashNavigationListener /> */}
+37 -1
View File
@@ -4,6 +4,8 @@ import {useAppStatus} from './appStatus';
// import {useGlobaleCash} from './eCash';
import {crashlyticsLogReport} from '../app/functions/crashlyticsLogs';
import {useSparkWallet} from './sparkContext';
import {useRootstockProvider} from './rootstockSwapContext';
import i18next from 'i18next';
// export function EcashNavigationListener() {
// const navigation = useNavigation();
@@ -38,6 +40,41 @@ import {useSparkWallet} from './sparkContext';
// return null;
// }
export function RootstockNavigationListener() {
const navigation = useNavigation();
const {didGetToHomepage} = useAppStatus();
const {pendingNavigation, setPendingNavigation} = useRootstockProvider();
const isNavigating = useRef(false); // Use a ref for local state
useEffect(() => {
if (!pendingNavigation) return;
if (!didGetToHomepage) {
setPendingNavigation(null);
return;
}
if (isNavigating.current) return;
crashlyticsLogReport(
`Navigating to confirm tx page in spark listener with: ${JSON.stringify(
pendingNavigation,
)}`,
);
isNavigating.current = true;
requestAnimationFrame(() => {
requestAnimationFrame(() => {
navigation.navigate('ErrorScreen', {
errorMessage: i18next.t('errormessages.receivedRootstock'),
});
isNavigating.current = false;
console.log('cleaning up navigation');
});
});
setPendingNavigation(null);
}, [pendingNavigation, didGetToHomepage]);
return null;
}
export function SparkNavigationListener() {
const navigation = useNavigation();
const {didGetToHomepage} = useAppStatus();
@@ -64,7 +101,6 @@ export function SparkNavigationListener() {
console.log('cleaning up navigation');
});
});
navigation.reset(pendingNavigation);
setPendingNavigation(null);
}, [pendingNavigation, didGetToHomepage]);
+12 -1
View File
@@ -40,6 +40,7 @@ export const RootstockSwapProvider = ({children}) => {
const subscribedIdsRef = useRef(new Set());
const activeSwapIdsRef = useRef(new Set()); // Track active swaps
const [signer, setSigner] = useState(null);
const [pendingNavigation, setPendingNavigation] = useState(null);
const wsRef = useRef(null);
const intervalRef = useRef(null);
@@ -281,6 +282,7 @@ export const RootstockSwapProvider = ({children}) => {
if (swap.type === 'submarine') {
if (status == 'invoice.set') {
await lockSubmarineSwap(swap, signer);
setPendingNavigation(true);
}
if (
[
@@ -363,8 +365,17 @@ export const RootstockSwapProvider = ({children}) => {
signer,
createSigner,
startRootstockEventListener,
pendingNavigation,
setPendingNavigation,
};
}, [provider, signer, createSigner, startRootstockEventListener]);
}, [
provider,
signer,
createSigner,
startRootstockEventListener,
pendingNavigation,
setPendingNavigation,
]);
return (
<RootstockSwapContext.Provider value={contextValue}>
+2 -1
View File
@@ -1561,7 +1561,8 @@
"sparkInvioceError": "There was a problem generating your Spark address. Please try again.",
"lightningInvioceError": "There was a problem generating your Lightning address. Please try again.",
"sparkConnectionError": "Spark connection failed. Please try again.",
"giftCardExpiration": "Gift cards can only be recovered for 7 days after they are sent. If this app is deleted or local storage is cleared after that time, your gift cards will be lost. Be sure to save the claim links or gift card codes somewhere safe."
"giftCardExpiration": "Gift cards can only be recovered for 7 days after they are sent. If this app is deleted or local storage is cleared after that time, your gift cards will be lost. Be sure to save the claim links or gift card codes somewhere safe.",
"receivedRootstock": "Rootstock payment received — your swap is starting. It may take up to a minute, so please keep the app open."
},
"loadingScreen": {
+2 -1
View File
@@ -1560,7 +1560,8 @@
"sparkInvioceError": "C'è stato un problema nella generazione del tuo indirizzo Spark. Riprova.",
"lightningInvioceError": "C'è stato un problema nella generazione del tuo indirizzo Lightning. Riprova.",
"sparkConnectionError": "Connessione Spark fallita. Riprova.",
"giftCardExpiration": "Le carte regalo possono essere recuperate solo entro 7 giorni dall'invio. Se questa app viene eliminata o l'archiviazione locale viene cancellata dopo tale periodo, le tue carte regalo andranno perse. Assicurati di salvare i link di richiesta o i codici delle carte regalo in un luogo sicuro."
"giftCardExpiration": "Le carte regalo possono essere recuperate solo entro 7 giorni dall'invio. Se questa app viene eliminata o l'archiviazione locale viene cancellata dopo tale periodo, le tue carte regalo andranno perse. Assicurati di salvare i link di richiesta o i codici delle carte regalo in un luogo sicuro.",
"receivedRootstock": "Pagamento Rootstock ricevuto: il tuo scambio sta iniziando. Potrebbe volerci fino a un minuto, quindi tieni l'app aperta."
},
"loadingScreen": {
+2 -1
View File
@@ -1386,7 +1386,8 @@
"sparkInvioceError": "Hubo un problema al generar tu dirección Spark. Intenta de nuevo.",
"lightningInvioceError": "Hubo un problema al generar tu dirección Lightning. Intenta de nuevo.",
"sparkConnectionError": "Error en la conexión con Spark. Intenta de nuevo.",
"giftCardExpiration": "Las tarjetas de regalo solo se pueden recuperar durante 7 días después de su envío. Si eliminas esta aplicación o borras el almacenamiento local después de ese tiempo, perderás tus tarjetas de regalo. Asegúrate de guardar los enlaces de solicitud o los códigos de las tarjetas de regalo en un lugar seguro."
"giftCardExpiration": "Las tarjetas de regalo solo se pueden recuperar durante 7 días después de su envío. Si eliminas esta aplicación o borras el almacenamiento local después de ese tiempo, perderás tus tarjetas de regalo. Asegúrate de guardar los enlaces de solicitud o los códigos de las tarjetas de regalo en un lugar seguro.",
"receivedRootstock": "Pago de Roostock recibido: su intercambio está comenzando. Puede tardar hasta un minuto, así que mantenga la aplicación abierta."
},
"loadingScreen": {
"message1": "Por favor no cierres la aplicación",