mirror of
https://github.com/kremalicious/blog.git
synced 2025-01-05 03:15:07 +01:00
actually catch transaction errors
This commit is contained in:
parent
fa7bb17f07
commit
ae398a8d2b
@ -37,22 +37,29 @@ export default function Web3Donation({ address }: { address: string }) {
|
|||||||
text: getTransactionMessage().waitingForUser
|
text: getTransactionMessage().waitingForUser
|
||||||
})
|
})
|
||||||
|
|
||||||
const tx = await signer.sendTransaction({
|
try {
|
||||||
to: address,
|
const tx = await signer.sendTransaction({
|
||||||
value: parseEther(amount.toString()) // ETH -> Wei
|
to: address,
|
||||||
})
|
value: parseEther(amount.toString()) // ETH -> Wei
|
||||||
setTransactionHash(tx.hash)
|
})
|
||||||
setMessage({
|
setTransactionHash(tx.hash)
|
||||||
status: 'loading',
|
setMessage({
|
||||||
text: getTransactionMessage().waitingConfirmation
|
status: 'loading',
|
||||||
})
|
text: getTransactionMessage().waitingConfirmation
|
||||||
|
})
|
||||||
|
|
||||||
await tx.wait()
|
await tx.wait()
|
||||||
|
|
||||||
setMessage({
|
setMessage({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
text: getTransactionMessage().success
|
text: getTransactionMessage().success
|
||||||
})
|
})
|
||||||
|
} catch (error) {
|
||||||
|
setMessage({
|
||||||
|
status: 'error',
|
||||||
|
text: error.message
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user