Skip to content

fix(keeper): use regexp instead of fmt.Sscanf to parse ErrInsufficientFunds in ClaimRewards#970

Open
Mayveskii wants to merge 1 commit intogonka-ai:mainfrom
Mayveskii:fix/parse-balance-error-robustness
Open

fix(keeper): use regexp instead of fmt.Sscanf to parse ErrInsufficientFunds in ClaimRewards#970
Mayveskii wants to merge 1 commit intogonka-ai:mainfrom
Mayveskii:fix/parse-balance-error-robustness

Conversation

@Mayveskii
Copy link
Copy Markdown

Problem

parseBalanceError uses fmt.Sscanf with hardcoded denom names nicoin/ngonka. If SDK changes error format, parse silently returns 0,0 making balance diagnostics useless.

Fix

Use compiled regexp matching amounts without hardcoded denom names.

Impact: robust parsing regardless of denomination, pre-compiled pattern has zero overhead

…Rewards

parseBalanceError used fmt.Sscanf with hardcoded denomination names
("nicoin", "ngonka"). If the SDK error message format changes or a
different denomination is used, the parse silently fails and logs
spendable=0 required=0 making the balance diagnostics useless.

Replace with a compiled regexp that matches the numeric amounts without
depending on specific denomination names. The pattern matches the stable
part of the Cosmos SDK ErrInsufficientFunds message:
  "spendable balance <N><denom> is smaller than <N><denom>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant