Skip to content

Detect chain network from address format instead of hardcoding tron - #24

Merged
KevinMB0220 merged 1 commit into
mainfrom
fix/issue-10-detect-chain-network
Sep 10, 2026
Merged

KevinMB0220 merged 1 commit into
mainfrom
fix/issue-10-detect-chain-network

Conversation

@Josue19-08

@Josue19-08 Josue19-08 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

apps/web/src/App.tsx hardcoded network: "tron" for every destination address, so RiskListPort.lookup (which keys on network:value) silently checked the wrong list for any non-Tron address.

Changes

  • Add detectChainNetwork() in packages/core, inferring tron (base58, T...) or ethereum (0x... hex) from the address format, returning other otherwise.
  • Use it in App.tsx instead of the hardcoded "tron" network.
  • Show a warning and skip analysis when the address matches neither format, instead of silently treating it as Tron.
  • Add unit tests covering Tron, Ethereum, and unrecognized formats.

Closes

Closes #10

Notes

No lint script is configured in the repo, so only test/typecheck/build were run.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added automatic detection for Tron and Ethereum address formats before analysis.
    • Analysis now uses the detected network instead of assuming every address belongs to Tron.
    • Unrecognized addresses display a validation error and clear any previous assessment.
  • Tests

    • Added coverage for valid Tron and Ethereum addresses, invalid formats, missing prefixes, and empty input.

RiskListPort.lookup keys on network:value, so hardcoding "tron" made
every non-Tron destination silently look up under the wrong network.
Infer the network from the address format and flag anything matching
neither Tron nor Ethereum instead of assuming Tron.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 31fbc6fe-a991-4c32-bff1-f3ae05cf76d0

📥 Commits

Reviewing files that changed from the base of the PR and between 5921a3a and c7244b8.

📒 Files selected for processing (4)
  • apps/web/src/App.tsx
  • packages/core/src/domain/services/__tests__/detectChainNetwork.test.ts
  • packages/core/src/domain/services/detectChainNetwork.ts
  • packages/core/src/index.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The application now detects Tron and Ethereum networks from destination address formats. It rejects unrecognized formats before analysis and passes the detected network to downstream risk checks.

Changes

Chain network detection

Layer / File(s) Summary
Network detector contract and validation
packages/core/src/domain/services/detectChainNetwork.ts, packages/core/src/index.ts, packages/core/src/domain/services/__tests__/detectChainNetwork.test.ts
Adds and exports detectChainNetwork. The service recognizes Tron and Ethereum formats and returns "other" for unsupported inputs. Tests cover valid and invalid formats.
Analysis network validation
apps/web/src/App.tsx
Validates the destination before analysis, displays an error for unsupported formats, clears previous assessments, and passes the detected network instead of always using Tron.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to c7244

Destination analysis now uses the detected Tron or Ethereum network rather than always using Tron, while unsupported address formats are blocked before analysis. No concrete current-head merge-blocking risk remains.

Suggested reviewers: kevinmb0220

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: detecting the chain network from the address format instead of hardcoding Tron.
Linked Issues check ✅ Passed The changes satisfy issue #10. They detect Tron and Ethereum address formats, return other for unsupported formats, prevent analysis for unsupported addresses, and use the detected network for downs…
Out of Scope Changes check ✅ Passed The changes are limited to the requested network detection service, application integration, package export, and related unit tests. No unrelated changes are present.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-10-detect-chain-network

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.

@KevinMB0220
KevinMB0220 merged commit 00d85fd into main Sep 10, 2026
2 checks passed
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.

Detect chain network from address format instead of hardcoding tron

2 participants