airswap-web icon indicating copy to clipboard operation
airswap-web copied to clipboard

Swap checks failed but still added to transactions list

Open dmosites opened this issue 2 years ago • 3 comments

Screen Shot 2022-05-16 at 3 01 56 PM

dmosites avatar May 16 '22 19:05 dmosites

@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.

piersss avatar May 26 '22 06:05 piersss

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.

gpxl-dev avatar May 26 '22 06:05 gpxl-dev

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.

robbestad avatar Jun 09 '22 07:06 robbestad