hiero-ledger / hiero-ledger/hiero-consensus-node
Unable to remove an existing token allowance if token is not associated in wallet
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
**Problem story:** A user cannot remove an token allowance related to the token if the token is not associated to the user's wallet. The user have to associate the token in order to remove the allowance, and then disassociate the token again afterwards which seems silly.
This is a VERY time consuming process when many allowances have been given over time, and over a long time tokens had been dissociated as part of the 'wallet cleansing' process (removing tokens with 0 balances in them). This can be quite common with SaucerSwap DEX where users buy and sell tokens over time, and allowances are require to sell the token, adding or removing tokens to the liquidity pool.
Over a long period of time, the total number of allowances given have increased and eventually users run into "MAX_ALLOWANCES_EXCEEDED". But when it comes to removing allowances, users can often encounter "TOKEN_NOT_ASSOCIATED_TO_ACCOUNT" when trying to remove an old allowance.
While it makes sense to have the token associated before giving an non-zero allowance. It does not make sense that it requires the token to be associated in order for the allowance to be removed (by setting 0 for allowance).
**Proposed solution:**
1. If allowance > 0, do check if the token is associated to the wallet.
2. If allowance = 0, skip the token association check. Optionally check if the allowance exists if it is needed.
This will make it easier for users to remove old allowances without having to go through the unnecessary steps to associate the token in order to remove an allowance and then dissociate the token again afterwards.
Contributor guide
Research direction
No file or test is named. Start by tracing the allowance-removal path and its token-association validation, then compare the handling of zero and non-zero allowances. Done means an existing allowance can be set to zero without token association, while non-zero allowance behavior remains protected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, blockchain
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100