Skip to content

feat(tron): upgrade to TIP-1193 protocol and add network change detection#20

Merged
bolom merged 1 commit intomasterfrom
feat/tron-tip-1193-protocol
Oct 22, 2025
Merged

feat(tron): upgrade to TIP-1193 protocol and add network change detection#20
bolom merged 1 commit intomasterfrom
feat/tron-tip-1193-protocol

Conversation

@bolom
Copy link
Contributor

@bolom bolom commented Oct 22, 2025

Summary

  • Upgrade TronLink event handling from deprecated events to modern TIP-1193 protocol standard
  • Add network change detection for mainnet ↔ testnet switches
  • Align Tron handler with EIP-1193 patterns used in EVM handler

Changes

Event Protocol Upgrade

  • Replace deprecated connect and networkChanged events with TIP-1193 standard chainChanged and accountsChanged
  • Update event listener cleanup to match new event names
  • Add proper comments explaining dual-channel event handling

Network Change Detection

  • Add setNode message handler to detect network switches (mainnet ↔ nile, etc.)
  • Extract chainId from nested message structure message.data.node.chainId
  • Convert chainId to string for consistency with other handlers

Code Quality

  • Improve comments to reflect both account AND network changes
  • Maintain symmetry between setup and teardown methods
  • Follow project conventions from EVM and Solana handlers

Test Plan

  • All existing tests pass
  • Linting checks pass
  • Build succeeds
  • Manual testing with TronLink wallet
  • Test account changes
  • Test network switches (mainnet ↔ nile)

Related Issues

Fixes issues with TronLink network change detection and modernizes event handling.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced TRON wallet event handling for network and account changes.
    • Improved detection and processing of node/network changes through updated event listeners and message handling.

…tion

- Replace deprecated connect/networkChanged events with TIP-1193 standard chainChanged/accountsChanged
- Add setNode message handler to detect network switches (mainnet ↔ nile, etc.)
- Update event listener cleanup to match new event names
- Improve comments to reflect dual-channel event handling (window messages + direct events)
- Align with EIP-1193 patterns used in EVM handler
@coderabbitai
Copy link

coderabbitai bot commented Oct 22, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR updates the TronLink wallet handler to adopt TIP-1193 protocol standards, replacing legacy event listeners (connect, networkChanged) with their standardized counterparts (chainChanged, accountsChanged), and adding support for node/network change messages via setNode action.

Changes

Cohort / File(s) Summary
TronLink Event Listener Alignment
src/core/wallets/tron_handler.js
Replaced window event listeners from connect and networkChanged to chainChanged and accountsChanged per TIP-1193 protocol. Added handling for setNode messages to update chainId. Updated disconnect cleanup to remove the new listeners instead of legacy ones.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • scionx-io/chain-connect#15: Modifies the same TronLink handler file with related changes to wallet connection/reconnection and event listener handling for account and chain changes.

Poem

🐰 The protocol hops to TIP-1193's beat,
Chainged and accountsChanged—events now sweet,
setNode whispers through window's embrace,
Modern TronLink handlers find their place! 🌟

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/tron-tip-1193-protocol

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a2df11 and 7917faf.

📒 Files selected for processing (1)
  • src/core/wallets/tron_handler.js (2 hunks)

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 and usage tips.

@bolom bolom merged commit 449b9a3 into master Oct 22, 2025
1 of 2 checks passed
@bolom bolom deleted the feat/tron-tip-1193-protocol branch October 22, 2025 21:08
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.

1 participant