Fix: remove outdated failed withdrawals #304
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Previously in #300, we wanted to find outdated failed withdrawals in the
localTxHistory
variable and remove them.However, in our tests, @Dawn-githup and I discovered that the
failed
status is not updated in thelocalTxHistory
variable.SImply put, here's the
localTxHistory
in withdrawal v1 list:localTxHistory
and save tolocalStorage
localTxHistory
fromlocalStorage
localTxHistory
is completed (comparing with a list from gwscan api), remove it from thelocalTxHistory
You can see there's no status check or update during the variable's lifecycle. Further more, items of the
localTxHistory
in the specific withdrawal v1 list don't have thestatus
property we need. Therefore, when we tried to check items'status
field of thelocalTxHistory
variable, it won't work because the property was contained.Fix
The fix here is to use the
pendingList
variable instead oflocalTxHistory
, which is a resolved pending list based on local pending withdrawals, but the status field is handled so it's notundefined
.Another issue left tho, is that items of
pendingList
don't have adate
field, so after we find a failed withdrawal frompendingList
, in order to find out if the failed withdrawal is outdated, we need to search for its local pending history from thelocalTxHistory
, which seems to be a performance bomb.