Skip to content

fix: eliminate no-explicit-any warnings in src/rpc/client.ts (closes #360) - #530

Merged
AbdulmalikAlayande merged 1 commit into
TegoLabs:mainfrom
aymide1ee:fix/eliminate-no-explicit-any-client
Jul 30, 2026
Merged

AbdulmalikAlayande merged 1 commit into
TegoLabs:mainfrom
aymide1ee:fix/eliminate-no-explicit-any-client

Conversation

@aymide1ee

Copy link
Copy Markdown
Contributor

Summary

Resolves #360 — eliminates all 46 @typescript-eslint/no-explicit-any warnings in src/rpc/client.ts.

Changes

  • Added 6 local type interfaces to replace any casts:
    • ErrorLike — for catch-block error handling
    • SorobanMetaLike — for sorobanMeta resource counters
    • SimulateTransactionCost / SimulateWithCost — for raw simulation cost fields
    • SendTransactionErrorResult — for send-transaction error responses
    • GetTransactionRawFields — for raw get-transaction fields
  • Removed serverAny casts — getLatestLedger(), getFeeStats(), and GetHealthResponse.latestLedger are now called using properly typed SDK methods
  • Changed executeWithRetry catch from error: any to error: unknown with ErrorLike cast
  • Typed buildAndSignFeeBump params as Transaction and SimulateTransactionSuccessResponse

Type-only refactor — zero behavior changes

All casts preserve the original runtime behavior. The double-cast as unknown as GetTransactionRawFields is intentional: the SDK types parse resultMetaXdr as xdr.TransactionMeta, but at runtime the RPC may still return a base64 string that extractResourceCosts expects.

Verification

Check Result
no-explicit-any warnings 0 (down from 46) ✅
npx tsc --noEmit Clean ✅
RPC tests (66 tests) All pass ✅

…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.
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Improved internal type safety across RPC requests, transaction submission, simulation, and polling.
    • Strengthened handling of transaction errors, diagnostics, timeouts, and resource-cost data.
    • No user-facing functionality or public API changes.

Walkthrough

The RPC client replaces any casts with local TypeScript interfaces for RPC errors, Soroban resource costs, transaction fields, simulation responses, and fee-bump transactions while preserving existing retry, submission, diagnostics, and polling behavior.

Changes

RPC client typing

Layer / File(s) Summary
Typed RPC contracts and retry access
src/rpc/client.ts
Adds local interfaces and applies them to error handling, Soroban metadata, ledger lookup, and fee statistics.
Typed simulation and submission handling
src/rpc/client.ts
Types simulation costs, transaction diagnostics, fee-bump construction, restore submission, payment errors, and bad-sequence parsing.
Typed transaction polling
src/rpc/client.ts
Types raw transaction metadata, fee, and ledger fields in successful and failed polling paths.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: abdulmalikalayande, stephan-thomas

Poem

A rabbit checked each RPC trail,
And typed the costs in every tale.
No any shadows hop along,
Errors now wear shapes so strong.
The ledger rests in fields precise—
“Hop hop!” cries Bun, “That’s nice!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing no-explicit-any warnings in src/rpc/client.ts.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the type-only refactor.
Linked Issues check ✅ Passed The changes match #360 by replacing any with local types or unknown in src/rpc/client.ts while preserving behavior.
Out of Scope Changes check ✅ Passed The PR stays within scope and only touches src/rpc/client.ts with type-related refactors.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 35d9237 and fdb6d5d.

📒 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!

Comment thread src/rpc/client.ts
@gitguardian

gitguardian Bot commented Jul 29, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
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
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. 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


🦉 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.

@aymide1ee

Copy link
Copy Markdown
Contributor Author

Please can you assign me points to this maintainer.

@AbdulmalikAlayande
AbdulmalikAlayande merged commit c81b930 into TegoLabs:main Jul 30, 2026
3 of 5 checks passed
AbdulmalikAlayande pushed a commit that referenced this pull request Aug 2, 2026
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.
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.

chore(lint): eliminate no-explicit-any warnings in src/rpc/client.ts

2 participants