fix(agentkit): compare EVM addresses case-insensitively in erc20, sushi and yelay - #1507
Open
creativityventures wants to merge 7 commits into
Open
creativityventures wants to merge 7 commits into
creativityventures wants to merge 7 commits into
Conversation
🟡 Heimdall Review Status
|
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.
Description
Three action providers compare EVM addresses as raw strings, so the same address written in a different case does not match. Addresses reach these providers from an LLM — the Zod schemas accept
^0x[a-fA-F0-9]{40}$, so any casing — and from external APIs, so this is not a hypothetical.erc20ActionProvider.ts·transferargs.tokenAddress === args.destinationAddressgetCode+ multicall, and only for as long as that second check holds. The Python SDK compares.lower()at this exact spot.sushiRouterActionProvider.ts·fetchDecimalstoken === nativeAddressnativeAddressfromsushi/evmis lowercase, so a checksummed native address falls through todecimals()on an address with no code, and the quote or swap fails with a contract error. Lines 314 and 435 of the same file already compare.toLowerCase().yelayActionProvider.ts· deposit / redeem / balancevault.address === args.vaultAddressVault not found.Lowercasing both sides is the convention already used elsewhere: 15 other address comparisons under
typescript/agentkit/srcdo it, including two in the sushi file being changed.Tests
pnpm --filter @coinbase/agentkit test— 906 passed (903 onmain, +3 added, one per fixed comparison). Each new test fails onmain:eslint -c .eslintrc.json "src/**/*.ts",prettier --checkandtsc --noEmitare all clean.I did not run one of the example chatbots for this one: it needs live RPC access and provider keys I don't have here. The three cases are covered at the unit level instead, using each provider's existing mocks — the sushi test asserts
readContractis never called, which is the observable difference between the native path and the ERC20 path.Checklist
Written with AI assistance (Claude); the diff is six files plus a changeset, and every number above is reproducible with the commands given.