Skip to content

fix: route provider auto-selection by operation capability (#17) - #25

Open
meridianmindx wants to merge 1 commit into
agntn:mainfrom
meridianmindx:fix/solana-balance-helius-skip
Open

fix: route provider auto-selection by operation capability (#17)#25
meridianmindx wants to merge 1 commit into
agntn:mainfrom
meridianmindx:fix/solana-balance-helius-skip

Conversation

@meridianmindx

Copy link
Copy Markdown

Closes #17

Problem

When HELIUS_API_KEY is present in the environment and a user queries explorers_balance for Solana (or runs balance without an explicit provider), auto-selection routed to helius. However, Helius Enhanced Transactions v0 does not expose an address balance endpoint, causing getBalance() to throw UnsupportedOperationError("getBalance", "helius").

Solution

  • Added capabilities to built-in provider metadata in src/providers/index.ts (evaluated statically without loading provider implementation modules).
  • Added supportsCapability(name, capability) to core registry.
  • Extended resolveProvider(preferred?, chain?, capability?) to consider operation capability when resolving candidate providers.
  • Passed operation capability from CLI commands (balance, tx, contract, tokens, transfers, gas, block), MCP tool handlers, and Pi/OMP extensions.
  • Verified in unit tests that balances on Solana skips Helius and selects Solscan, while txHistory and txDetail still route to Helius.
  • Verified in registry unit tests that declared built-in capabilities strictly match loaded class capabilities.
  • Guarded JSON.parse reviver context to maintain compatibility with Node < 21.

Verification

  • pnpm test:run → 23/23 test files passed, 237/237 tests passing green.
  • pnpm typecheck (tsc --noEmit) → 0 errors.
  • pnpm build (obuild) → Clean bundle generation with 0 B side effects across all provider chunks.
  • npx oxlint & npx oxfmt --check → 0 warnings, 0 errors, 100% formatted.

Base EVM Payout Address: 0xcFDa9f32d292661740a6d0B4c00867E34c05c56D

When resolving providers for an operation (e.g. getBalance on Solana),
filter out providers that declare the capability as unsupported so that
keyless/fallback providers with capability support (like solscan) are
chosen rather than throwing UnsupportedOperationError from a configured
provider that lacks the operation (like helius).

- Add `capabilities` to built-in provider metadata in `src/providers/index.ts`
- Expose `supportsCapability(name, capability)` from core registry
- Pass requested capability to `resolveProvider()` across CLI commands, MCP server, and extensions
- Verify built-in metadata matches loaded class capabilities in registry unit tests
- Add resolution test verifying `balances` on Solana skips Helius while `txHistory` retains it
- Guard JSON.parse reviver context for node < 21 compatibility
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.

Solana balance routed to helius which lacks getBalance

1 participant