Repository navigation
fix: eliminate no-explicit-any warnings in src/rpc/client.ts (closes #360) - #530
Conversation
…egoLabs#360) Replace all 46 type casts in src/rpc/client.ts with properly typed local interfaces: - ErrorLike for catch-block error handling - SorobanMetaLike for sorobanMeta resource counters - SimulateTransactionCost / SimulateWithCost for simulation cost fields - SendTransactionErrorResult for send-transaction error responses - GetTransactionRawFields for raw get-transaction fields Also remove serverAny casts by using directly-typed SDK methods: getLatestLedger(), getFeeStats(), and GetHealthResponse.latestLedger. Zero no-explicit-any warnings, clean tsc compilation, all 66 RPC tests pass.
|
@aymide1ee Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe RPC client replaces ChangesRPC client typing
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/rpc/client.ts`:
- Around line 92-95: Update the catch handling in the RPC client to validate the
caught unknown value before reading code, response.status, or message. Ensure
nullish and non-object values cannot throw, and only call includes when message
is a string, while preserving the existing timeout detection and status fallback
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: fbc526db-3f00-44fc-a935-3f818d0cea22
📒 Files selected for processing (1)
src/rpc/client.ts
📜 Review details
🔇 Additional comments (15)
src/rpc/client.ts (15)
5-5: LGTM!
18-64: LGTM!
253-255: LGTM!
305-329: LGTM!
582-585: LGTM!
677-689: LGTM!
700-700: LGTM!
737-737: LGTM!
764-776: LGTM!
836-848: LGTM!
893-893: LGTM!
910-917: LGTM!
961-961: LGTM!
978-984: LGTM!
995-995: LGTM!
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Generic High Entropy Secret | ded54f4 | tests/commands/guard-cli-export-import.test.ts | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
|
Please can you assign me points to this maintainer. |
Every `any` cast replaced with a precisely-named interface (ErrorLike, SorobanMetaLike, SimulateWithCost, SendTransactionErrorResult, GetTransactionRawFields); reviewed the full diff line-by-line, every runtime property access/behavior is preserved exactly. Verified locally: lint, typecheck, full suite (1042/1042, including all 66 rpc tests), build, and audit all clean. Closes #360.
Summary
Resolves #360 — eliminates all 46
@typescript-eslint/no-explicit-anywarnings insrc/rpc/client.ts.Changes
anycasts:ErrorLike— for catch-block error handlingSorobanMetaLike— for sorobanMeta resource countersSimulateTransactionCost/SimulateWithCost— for raw simulation cost fieldsSendTransactionErrorResult— for send-transaction error responsesGetTransactionRawFields— for raw get-transaction fieldsserverAnycasts —getLatestLedger(),getFeeStats(), andGetHealthResponse.latestLedgerare now called using properly typed SDK methodsexecuteWithRetrycatch fromerror: anytoerror: unknownwithErrorLikecastbuildAndSignFeeBumpparams asTransactionandSimulateTransactionSuccessResponseType-only refactor — zero behavior changes
All casts preserve the original runtime behavior. The double-cast
as unknown as GetTransactionRawFieldsis intentional: the SDK types parseresultMetaXdrasxdr.TransactionMeta, but at runtime the RPC may still return a base64 string thatextractResourceCostsexpects.Verification
no-explicit-anywarningsnpx tsc --noEmit