Skip to content

Commit

Permalink
Merge pull request #7905 from LedgerHQ/bugfix/wallet-api-llm-sign-mes…
Browse files Browse the repository at this point in the history
…sage-retry

fix(wallet-api): only call success and fail handlers when closing the flow on LLM
  • Loading branch information
Justkant authored Sep 26, 2024
2 parents 00f1d54 + f16375d commit bb822fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .changeset/clever-rocks-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"live-mobile": patch
---

fix(wallet-api): only call success and fail handlers when closing the flow on LLM

Allows to properly retry the sign message without sending an error through the wallet-api
We also only send the success when we actually close the last success screen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect } from "react";
import React, { useCallback } from "react";
import { StyleSheet } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { CompositeScreenProps, useTheme } from "@react-navigation/native";
Expand All @@ -22,14 +22,12 @@ export default function ValidationError({ navigation, route }: Navigation) {
const { colors } = useTheme();
const { error, onFailHandler } = route.params;

useEffect(() => {
const onClose = useCallback(() => {
if (onFailHandler && error) {
onFailHandler(error);
}
}, [onFailHandler, error]);
const onClose = useCallback(() => {
navigation.getParent<StackNavigatorNavigation<BaseNavigatorStackParamList>>().pop();
}, [navigation]);
}, [error, navigation, onFailHandler]);
const retry = useCallback(() => {
navigation.goBack();
}, [navigation]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect } from "react";
import React, { useCallback } from "react";
import { View, StyleSheet } from "react-native";
import { useTranslation } from "react-i18next";
import { CompositeScreenProps, useTheme } from "@react-navigation/native";
Expand All @@ -25,14 +25,13 @@ export default function ValidationSuccess({
const { t } = useTranslation();
const { signature, onConfirmationHandler } = route.params;

useEffect(() => {
const onClose = useCallback(() => {
if (onConfirmationHandler && signature) {
onConfirmationHandler(signature);
}
}, [onConfirmationHandler, signature]);
const onClose = useCallback(() => {
navigation.getParent<StackNavigatorNavigation<BaseNavigatorStackParamList>>().pop();
}, [navigation]);
}, [navigation, onConfirmationHandler, signature]);

return (
<View
style={[
Expand Down

0 comments on commit bb822fa

Please sign in to comment.