1
0
mirror of https://github.com/kremalicious/blog.git synced 2025-01-03 02:15:08 +01:00

actually catch transaction errors

This commit is contained in:
Matthias Kretschmann 2020-01-13 22:07:48 +01:00
parent fa7bb17f07
commit ae398a8d2b
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -37,22 +37,29 @@ export default function Web3Donation({ address }: { address: string }) {
text: getTransactionMessage().waitingForUser
})
const tx = await signer.sendTransaction({
to: address,
value: parseEther(amount.toString()) // ETH -> Wei
})
setTransactionHash(tx.hash)
setMessage({
status: 'loading',
text: getTransactionMessage().waitingConfirmation
})
try {
const tx = await signer.sendTransaction({
to: address,
value: parseEther(amount.toString()) // ETH -> Wei
})
setTransactionHash(tx.hash)
setMessage({
status: 'loading',
text: getTransactionMessage().waitingConfirmation
})
await tx.wait()
await tx.wait()
setMessage({
status: 'success',
text: getTransactionMessage().success
})
setMessage({
status: 'success',
text: getTransactionMessage().success
})
} catch (error) {
setMessage({
status: 'error',
text: error.message
})
}
}
return (