Display transaction error in wallet embed component

This commit is contained in:
Adw8 2024-11-11 10:21:34 +05:30
parent 198ccd98c3
commit cd640e77f8

View File

@ -1,6 +1,7 @@
import React, { useEffect, useState, useCallback, useRef } from 'react';
import { ScrollView, View } from 'react-native';
import {
ActivityIndicator,
Button,
Text,
TextInput,
@ -193,7 +194,10 @@ export const WalletEmbed = () => {
setIsTxRequested(true);
} catch (error) {
console.error('Error processing transaction request:', error);
if (!(error instanceof Error)) {
throw error;
}
setTxError(error.message);
}
}, [networksData]);
@ -247,8 +251,10 @@ export const WalletEmbed = () => {
console.error('No event source available to send message');
}
} catch (error) {
console.error('Transaction error:', error);
setTxError('Transaction failed');
if (!(error instanceof Error)) {
throw error;
}
setTxError(error.message);
} finally {
setIsTxLoading(false);
}
@ -314,7 +320,7 @@ export const WalletEmbed = () => {
mode="contained"
onPress={acceptRequestHandler}
loading={isTxLoading}
disabled={!transactionDetails.balance || !fees}
disabled={!transactionDetails.balance || !fees || isTxLoading}
>
{isTxLoading ? 'Processing' : 'Yes'}
</Button>
@ -328,11 +334,21 @@ export const WalletEmbed = () => {
</Button>
</View>
</>
) : null}
) : (
<View style={styles.spinnerContainer}>
<Text style={styles.LoadingText}>Loading...</Text>
<ActivityIndicator size="large" color="#0000ff" />
</View>
)}
<TxErrorDialog
error={txError!}
visible={!!txError}
hideDialog={() => setTxError(null)}
hideDialog={() => {
setTxError(null)
if (window.parent) {
window.parent.postMessage('closeIframe', '*');
}
}}
/>
</>
);