diff --git a/components/AttestationButton.tsx b/components/AttestationButton.tsx index f8acd4b30..8a47e2f55 100644 --- a/components/AttestationButton.tsx +++ b/components/AttestationButton.tsx @@ -10,28 +10,28 @@ import NostrichNotLoaded from '../assets/images/SVG/Nostrich_not-loaded.svg'; import NostrichValid from '../assets/images/SVG/Nostrich_valid.svg'; import NostrichInvalid from '../assets/images/SVG/Nostrich_invalid.svg'; import NostrichNotFound from '../assets/images/SVG/Nostrich_not-found.svg'; - export default function AttestationButton(props: any) { const { navigation, hash, amount_msat } = props; const [attestationStatus, setAttestationStatus] = useState('neutral'); const [loading, setLoading] = useState(false); const [attestations, setAttestations] = useState([]); + type attestationStatus = 'neutral' | 'success' | 'warning' | 'error'; return ( { + onPress={ async () => { if (attestationStatus === 'neutral') { setLoading(true); - stores.lightningAddressStore - .lookupAttestations(hash, amount_msat) - .then(({ attestations, status }) => { - setAttestations(attestations); - setAttestationStatus(status || ''); - setLoading(false); - }) - .catch(() => { - setLoading(false); - }); + try { + const { attestations, status } = await stores.lightningAddressStore.lookupAttestations(hash, amount_msat); + setAttestations(attestations); + setAttestationStatus(status || '' || 'error'); + } catch (error){ + console.error('Error fetching attestations:', error); + setAttestationStatus('error' || ''); + } finally { + setLoading(false); + } } else { if (attestationStatus === 'success') { navigation.navigate('Attestation', {