Repository navigation
fix: refuse bad address checksum on read actions instead of throwing - #114
Merged
portdeveloper merged 1 commit intoOct 2, 2026
Merged
Conversation
On get_token_balance and get_nfts, passing a mixed-case 0x address whose EIP-55 checksum failed bypassed regex address checks and reached ethers unchecked, throwing a raw INVALID_ARGUMENT error instead of returning a refusal string. Validate the address checksum on both read paths: - get_token_balance catches checksum errors from resolveToken and returns a refusal matching prepareTokenSend - get_nfts validates the owner address checksum with toChecksumAddress and returns a refusal matching resolveSend Closes portdeveloper#111
This was referenced Oct 2, 2026
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.
What this changes
Closes #111
get_token_balanceandget_nftsaccepted mixed-case 0x addresses with invalid EIP-55 checksums becauseisAddress()only tests0x + 40 hex. This allowed malformed addresses to bypass initial checks and reach ethers unchecked, throwing rawINVALID_ARGUMENT: bad address checksumerrors out ofrunActioninstead of returning the standardRefused: …line.This PR hardens both read paths upfront before ethers is touched:
get_token_balance: catches checksum failures fromresolveToken(input)and returnsRefused: invalid token address "<token>" (checksum failed), matchingprepareTokenSend.get_nfts: validates theowneraddress withtoChecksumAddressbefore callingwallet.getNfts(owner), returningRefused: "<owner>" is not a valid address (checksum failed), matchingresolveSend.get_token_balance(test/tools.test.mjs) andget_nfts(test/nft.test.mjs).How I tested it
npm run buildsucceedsnpm testpasses full suite (537 passed, 0 failed, 2 skipped)0x534B2f3A21130D7A60830C2Df862319E593943A3:runAction({ action: "get_token_balance", token: BAD })returnsRefused: invalid token address "0x534B..." (checksum failed)withisRefusal: truerunAction({ action: "get_nfts", address: BAD })returnsRefused: "0x534B..." is not a valid address (checksum failed)withisRefusal: trueModel / platform tested on:
Node v24.16.0 on Windows x64
Scope check
Conventions
npm(not pnpm/yarn) and did not add a globalsodium-nativeoverride..env, seeds, keys, or model weights.