Conversation
WalkthroughAdds a new dynamic Solana CA symbol/token lookup provider and comprehensive tests; provider extracts Solana addresses from messages, queries on-chain metadata (symbol, type, decimals, supply), filters token types, formats results, and is registered only when the spartan-intel plugin is absent. Changes
Sequence Diagram(s)sequenceDiagram
participant Runtime
participant caLookupProvider
participant SolanaService
participant OnChainRPC as On-Chain RPC
Runtime->>caLookupProvider: get(runtime, message, state)
caLookupProvider->>SolanaService: getService(SOLANA_SERVICE_NAME)
alt Service Available
SolanaService-->>caLookupProvider: service
caLookupProvider->>SolanaService: detectPubkeysFromString(text)
SolanaService-->>caLookupProvider: addresses[]
alt Addresses Found
par Parallel metadata fetch
caLookupProvider->>OnChainRPC: getTokenSymbol(address)
caLookupProvider->>OnChainRPC: getTokenType(address)
caLookupProvider->>OnChainRPC: getDecimals(address)
caLookupProvider->>OnChainRPC: getSupply(address)
and Filter & Aggregate
OnChainRPC-->>caLookupProvider: metadata
caLookupProvider->>caLookupProvider: filter token-type entries
caLookupProvider->>caLookupProvider: assemble data, values, text
end
caLookupProvider-->>Runtime: { data, values, text }
else No Addresses Found
caLookupProvider-->>Runtime: false
end
else Service Unavailable
SolanaService-->>caLookupProvider: null
caLookupProvider-->>Runtime: false
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (3)
__tests__/providers/ca-lookup.test.ts(1 hunks)src/index.ts(3 hunks)src/providers/ca-lookup.ts(1 hunks)
🔇 Additional comments (18)
src/index.ts (3)
18-18: LGTM!The import is correctly placed with other provider imports.
53-53: LGTM!Formatting improvement for consistency.
63-63: LGTM!Using structured logging with the error object is a best practice that improves debuggability.
src/providers/ca-lookup.ts (7)
1-14: LGTM!The documentation clearly explains the provider's purpose and behavior. Good practice to note that no LLM calls are made.
15-26: LGTM!The provider metadata is well-defined and the service availability check with early return follows best practices.
28-37: LGTM!Safe handling of optional message content with appropriate early return when no addresses are found.
39-61: LGTM!Efficient parallel data fetching with appropriate error handling. Good practice to handle supply fetch errors separately since it may fail independently.
72-92: Verify the type filtering logic is intentional.Line 77 uses
type === 'Token' || type.includes('Token')which will match any type containing "Token" (e.g., "Token Account", "Token-2022", "TokenProgram"). Based on the test at line 137 inca-lookup.test.tswhich expects "Wallet" to be filtered out, this appears intentional, but please confirm this matches the desired behavior for all token-related account types.
94-97: LGTM!Appropriate handling for the case where addresses are detected but none are tokens.
99-125: LGTM!Clean output formatting with both structured data and human-readable text. The separation of
lookupCount(total addresses) andresolvedCount(valid tokens) provides useful insight into filtering results.__tests__/providers/ca-lookup.test.ts (8)
1-33: LGTM!Comprehensive test setup with appropriate mocks and defaults. The mock structure accurately reflects the runtime interfaces.
35-49: LGTM!Test properly verifies the early return behavior when no addresses are detected.
51-76: LGTM!Comprehensive test case that validates the complete flow from address detection to formatted output. Good coverage of both data structure and text formatting.
78-109: LGTM!Well-structured test for multiple addresses that validates both the count and content of results.
111-122: LGTM!Good coverage of the error path when the Solana service is unavailable, including verification of logging behavior.
124-155: LGTM!Excellent test coverage of the filtering logic. The verification of both
lookupCount(2) andresolvedCount(1) demonstrates that the provider correctly distinguishes between detected addresses and valid tokens.
157-177: LGTM!Good coverage of error handling when RPC calls fail. Verifies both the return value and error logging behavior.
179-183: LGTM!Simple but essential test that validates the provider's metadata configuration.
Note
Introduces a Solana CA lookup provider to fetch on-chain token details from message addresses and registers it only when spartan-intel isn't loaded, with comprehensive tests.
src/providers/ca-lookup.ts(SOLANA_CA_SYMBOL_LOOKUP) to extract addresses from messages and fetch on-chain token data (symbol,type,decimals,supply), filtering non-token addresses and handling errors.src/index.ts):caLookupProvideronly ifspartan-intelplugin is absent; minor logging/formatting tweaks.__tests__/providers/ca-lookup.test.tscovering no addresses, single/multiple addresses, missing service, non-token filtering, error handling, and provider metadata.Written by Cursor Bugbot for commit 8be9e87. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
New Features
Tests