Skip to content

fix: build spec-compliant TRON transactions for WalletConnect signing#5638

Open
enesozturk wants to merge 3 commits intomainfrom
fix/ton-wc-send-message-params
Open

fix: build spec-compliant TRON transactions for WalletConnect signing#5638
enesozturk wants to merge 3 commits intomainfrom
fix/ton-wc-send-message-params

Conversation

@enesozturk
Copy link
Copy Markdown
Contributor

Summary

  • TronWalletConnectConnector now builds proper unsigned transactions via the Blockchain API's tron_createTransaction method before sending them to wallets via tron_signTransaction, then broadcasts via tron_broadcastTransaction
  • TronConnectConnector (injected wallets) refactored to use the Blockchain API instead of hardcoded TronGrid URLs
  • Added TRON chains (tron:0x2b6653dc, tron:0xcd8690dc) to WC_HTTP_RPC_SUPPORTED_CHAINS
  • Added chainDefault RPC URLs to TRON chain definitions as fallbacks

Problem

The TronWalletConnectConnector.sendTransaction() was sending a simplified {to, from, value} object as the transaction parameter to tron_signTransaction. According to the WalletConnect TRON RPC spec, wallets expect a full unsigned TRON transaction object with raw_data, raw_data_hex, txID, and visible fields.

Wallets implementing the spec correctly (e.g. JustLend DAO) reject these malformed transaction objects.

Solution

The connector now follows a 3-step flow:

  1. Build unsigned transaction via Blockchain API (tron_createTransaction)
  2. Sign the full transaction object via WalletConnect (tron_signTransaction)
  3. Broadcast the signed transaction via Blockchain API (tron_broadcastTransaction)

All TRON fullnode interactions are routed through our Blockchain API infrastructure instead of hardcoding third-party TronGrid URLs.

Dependencies

  • Requires reown-com/blockchain-api#1396 to be deployed first (adds tron_createTransaction wrapper to the Blockchain API)

Test plan

  • pnpm build — 24/24 tasks successful
  • Unit tests — 5 tests covering happy path, createTransaction failure, signing failure, broadcast failure, and signMessage
  • pnpm -w run prettier:format
  • Manual test: connect TRON wallet via WalletConnect, send transaction, verify wallet receives proper tx object

🤖 Generated with Claude Code

enesozturk and others added 2 commits February 27, 2026 17:46
…ormat

The TonWalletConnectConnector was passing sendMessage params through
without converting field names to the snake_case format required by
the WalletConnect TON JSON-RPC spec. This caused wallets to fail with
"Messages are absent" because:

1. Field names were camelCase (validUntil, extraCurrency) instead of
   snake_case (valid_until, extra_currency) as required by the spec
2. Params were wrapped in an array, but the sample wallet's
   approveTonRequest handler passes request.params directly to
   sendMessage without unwrapping — unlike signData which correctly
   unwraps with request.params[0]

Changes:
- Convert validUntil to valid_until with a default 60s expiry
- Convert extraCurrency to extra_currency in message objects
- Ensure amount is always a string (wallets validate typeof)
- Send params as a plain object instead of array for compatibility

The injected wallet connector (TonConnectConnector) already handled
this conversion correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The TronWalletConnectConnector was sending simplified {to, from, value}
objects via tron_signTransaction, but the WC spec requires full unsigned
transaction objects (with raw_data, raw_data_hex, txID, visible).

Changes:
- TronWalletConnectConnector now builds unsigned tx via Blockchain API's
  tron_createTransaction, sends full tx to wallet for signing, then
  broadcasts via tron_broadcastTransaction
- TronConnectConnector refactored to use Blockchain API instead of
  hardcoded TronGrid URLs
- Added TRON chains to WC_HTTP_RPC_SUPPORTED_CHAINS
- Added chainDefault RPC URLs to TRON chain definitions as fallbacks
- Added unit tests for the WC connector transaction flow

Depends on: reown-com/blockchain-api#1396

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 10, 2026

⚠️ No Changeset found

Latest commit: 3f0972d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
appkit-demo Ready Ready Preview, Comment Apr 17, 2026 9:15am
appkit-gallery Ready Ready Preview, Comment Apr 17, 2026 9:15am
appkit-headless-sample-app Ready Ready Preview, Comment Apr 17, 2026 9:15am
appkit-laboratory Ready Ready Preview, Comment Apr 17, 2026 9:15am
9 Skipped Deployments
Project Deployment Actions Updated (UTC)
appkit-basic-example Ignored Ignored Apr 17, 2026 9:15am
appkit-basic-sign-client-example Ignored Ignored Apr 17, 2026 9:15am
appkit-basic-up-example Ignored Ignored Apr 17, 2026 9:15am
appkit-ethers5-bera Ignored Ignored Apr 17, 2026 9:15am
appkit-nansen-demo Ignored Ignored Apr 17, 2026 9:15am
appkit-wagmi-cdn-example Ignored Ignored Apr 17, 2026 9:15am
ethereum-provider-wagmi-example Ignored Ignored Apr 17, 2026 9:15am
next-wagmi-solana-bitcoin-example Ignored Ignored Apr 17, 2026 9:15am
vue-wagmi-example Ignored Ignored Apr 17, 2026 9:15am

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

Visual Regression Test Results ✅ Passed

⚠️ 15 visual change(s) detected

Chromatic Build: https://www.chromatic.com/build?appId=6493191bf4b10fed8ca7353f&number=875
Storybook Preview: https://6493191bf4b10fed8ca7353f-xiisowvsus.chromatic.com/

👉 Please review the visual changes in Chromatic and accept or reject them.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

Warnings
⚠️

🌐 Non-company domain introduced (host: api.trongrid.io) in packages/appkit/src/networks/tron/tron.ts (line 10): https://api.trongrid.io

⚠️

🌐 Non-company domain introduced (host: api.trongrid.io) in packages/adapters/tron/src/tests/TronWalletConnectConnector.test.ts (line 49): https://api.trongrid.io

⚠️

🌐 Non-company domain introduced (host: nile.trongrid.io) in packages/appkit/src/networks/tron/tronNile.ts (line 10): https://nile.trongrid.io

⚠️

🌐 Non-company domain introduced (host: api.shasta.trongrid.io) in packages/appkit/src/networks/tron/tronShasta.ts (line 10): https://api.shasta.trongrid.io

⚠️

🌐 Non-company domain introduced (host: api.trongrid.io) in packages/adapters/tron/src/tests/TronWalletConnectConnector.test.ts (line 49): https://api.trongrid.io

Generated by 🚫 dangerJS against 3f0972d

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

📦 Bundle Size Check

All bundles are within size limits

📊 View detailed bundle sizes

> @reown/appkit-monorepo@1.7.1 size /home/runner/work/appkit/appkit


> size-limit

@reown/appkit - Main Entry
Size limit:   80 kB
Size:         75.72 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 356 ms   on Snapdragon 410
Total time:   1.9 s
@reown/appkit/react
Size limit:   235 kB
Size:         234.89 kB with all dependencies, minified and gzipped
Loading time: 4.6 s     on slow 3G
Running time: 826 ms    on Snapdragon 410
Total time:   5.5 s
@reown/appkit/vue
Size limit:   80 kB
Size:         75.72 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 197 ms   on Snapdragon 410
Total time:   1.7 s
@reown/appkit-scaffold-ui
Size limit:   220 kB
Size:         214.18 kB with all dependencies, minified and gzipped
Loading time: 4.2 s     on slow 3G
Running time: 584 ms    on Snapdragon 410
Total time:   4.8 s
@reown/appkit-ui
Size limit:   500 kB
Size:         13.16 kB with all dependencies, minified and gzipped
Loading time: 258 ms   on slow 3G
Running time: 43 ms    on Snapdragon 410
Total time:   300 ms

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.46% 39832 / 50765
🔵 Statements 78.46% 39832 / 50765
🔵 Functions 76.13% 4259 / 5594
🔵 Branches 86.62% 9675 / 11169
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/adapters/tron/src/connectors/TronWalletConnectConnector.ts 77.41% 47.82% 30.76% 77.41% 36-37, 40-41, 44-45, 48-51, 54-57, 63-64, 80-81, 90-91, 162-163, 167-168, 171-172, 182-183
packages/appkit-utils/src/CaipNetworkUtil.ts 99.56% 98.8% 95.65% 99.56% 268
packages/appkit/src/networks/tron/tron.ts 100% 100% 100% 100%
packages/appkit/src/networks/tron/tronNile.ts 100% 100% 100% 100%
packages/appkit/src/networks/tron/tronShasta.ts 100% 100% 100% 100%
Generated in workflow #17068 for commit 3f0972d by the Vitest Coverage Report Action

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