fix(parse_wei): match WEI key against uppercased currency#1
Open
abhicris wants to merge 1 commit into
Open
Conversation
The multiplier lookup uppercases the currency suffix, but the dict had a
lowercase 'wei' key, so 'X wei' fell through to the default ETH multiplier
and returned X * 10**18 instead of X.
The existing test_parse_wei case 'parse_wei("1000000000000000000 wei") == 10**18'
asserts the correct behavior — this fix makes it actually hold.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
parse_wei()uppercases the currency suffix before looking it up in the multiplier dict, but the dict key is lowercase\"wei\". Soparse_wei(\"X wei\")andparse_wei(\"X WEI\")both miss the lookup and fall through to the default ETH multiplier — returningX * 10**18instead ofX.The existing test in
tests/test_payment_protocol.pyalready asserts the correct behavior:```python
assert parse_wei("1000000000000000000 wei") == 10**18
```
…but the test currently fails (or has never been run against this code path) because the function returns
10**36. One-character fix: change the dict key to\"WEI\"so the existing.get(currency.upper(), …)lookup hits.This mirrors the upstream
kcolbchain/switchboardfork. AgentEscrow's amount parsing in client tooling needs to be exact for protocol-level escrow accounting.Diff
1 line changed, no new files.