airswap-web
airswap-web copied to clipboard
Swap checks failed but still added to transactions list

@robbestad This is caused by a bug I mentioned in this PR: https://github.com/airswap/airswap-web/pull/527.
The dispatch(declineTransaction(e.message)); in ordersSlice.ts does not work properly because the e.message is a string and not an object. So some transactions are not handled properly and stay in "processing" status. We should fix this in another ticket.
Then @gpxl-dev also mentioned in the dev chat we shouldn't use catch
to further handle transactions anyway, it's conventionally only used for unexpected errors:
I think the catch block and/or handleOrderError needs to account for a completely unexpected error (e.g. accessing a property of an undefined variable or something like that), and should probably console.log them to avoid swallowing them silently. (edited)
So the best solution to this ticket would be to find a way to listen for RPC errors and handle them accordingly (using declineTransaction
), and also prevent them from going to the catch
block.
Just to clarify I think it's fine to handle expected errors in the catch but we also need to consider those we haven't considered as well - in other words, assume nothing about the error.
We already have a listener set up for contracts. As long as they emit an error event it should be very easy to add this declineTransaction
functionality there. Debugging this.