Check allowance before depositing and skip token.approve #1642
Labels
enhancement
New feature or request
optimization ⚡
Optimizations for the implementation or protocol
sdk 🖥
Description
Very small issue. We should check token's allowance before depositing (to UDC deposit, on
channelOpen
orchannelDeposit
. If it's enough, we should skipapprove
and deposit directly.Metamask's UI allows the user to edit the allowance required (instead of the standard value provided to
approve
calls, which are usually exactly the amount to deposit in the LC). If we do check it, users planning to do multiple deposits (e.g. for tests) can edit the allowance on Metamask and put a (possibly very) high value there, and next deposits would only require the actual beneficiary contract transaction (UDC or TokenNetworks), saving a possibly long waiting time for approval.Note that, if editing in Metamask UI, it's advisable to also increase in a couple of thousand the gas limit (advanced gas edit), as a different value can cause a different gas requirement and could make tx to fail.
Acceptance criteria
Tasks
The text was updated successfully, but these errors were encountered: