Conversation
…unknown - Changed parseTx parameter from `msgHash: string` to `txHashOrTx: unknown` - Added type checking to convert unknown to string for use - Follows the pattern established in TronChainAdapter.ts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…te parse - Add TonTx and TonTxMessage types to packages/chain-adapters/src/ton/types.ts - Create private parse() helper method in TonChainAdapter.ts following Tron and SecondClassEvmAdapter patterns - parse() method handles: - Transaction status determination (aborted/success) - Transfer direction detection (send/receive) - Building transfers array from in_msg and out_msgs - Returning properly structured Transaction object - Update parseTx() to call parse() after fetching transaction data - Improve error handling when transaction is not found Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…dle TON token transfers - Add parseJettonTransfers method to fetch and parse Jetton transfers from Toncenter v3 API - Update parseTx to include Jetton transfers in transaction data - Use address_book to convert raw addresses to user-friendly format - Support both send and receive transfer types for Jettons Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…e import - Removed unused TonTxMessage type import from TonChainAdapter.ts - Lint check passes - Package build succeeds (all 8 packages compile) - Full type-check requires Java for OpenAPI generator (pre-existing infrastructure requirement) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR implements transaction history retrieval for the TON chain adapter, including batching and pagination support. It adds jetton (TON token) transfer parsing and address normalization, refactors the public Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant getTxHistory
participant requestQueue
participant parseTx
participant parseJettonTransfers
participant addressBook
Client->>getTxHistory: getTxHistory(input)
activate getTxHistory
getTxHistory->>getTxHistory: Initialize cursor & pagination
loop Until no more results
getTxHistory->>requestQueue: Queue fetch request
requestQueue->>requestQueue: Fetch transactions (cursor, pageSize)
requestQueue-->>getTxHistory: txs array
loop For each transaction
getTxHistory->>parseTx: parseTx(tx, pubkey)
activate parseTx
parseTx->>parse: parse(tx, pubkey, txid)
activate parse
parse->>addressBook: Normalize in_msg/out_msgs
addressBook-->>parse: Resolved addresses
parse-->>parseTx: Transaction with transfers
deactivate parse
parseTx->>parseJettonTransfers: parseJettonTransfers(txHash, pubkey)
activate parseJettonTransfers
parseJettonTransfers-->>parseTx: Jetton transfers
deactivate parseJettonTransfers
parseTx-->>getTxHistory: Combined transaction
deactivate parseTx
end
getTxHistory->>getTxHistory: Update cursor
end
getTxHistory-->>Client: TxHistoryResponse
deactivate getTxHistory
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20-25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
…n-t-parsing-txs-properly-
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@packages/chain-adapters/src/ton/TonChainAdapter.ts`:
- Around line 443-447: Validate the incoming cursor before converting to an
offset: in the scope where cursor and offset are initialized (used by
fetchTxHistory), check that cursor is a valid numeric string (e.g., digits only
or Number.isFinite(Number(cursor))) and only then set offset = parseInt(cursor,
10); otherwise default offset to 0 (or handle invalid cursor explicitly). Update
the initialization around the cursor/offset variables so offset cannot become
NaN and ensure fetchTxHistory uses this validated offset.
- Around line 796-872: The catch block in the jetton transfer fetch silently
swallows errors; change the try/catch around the this.httpApiRequest call in
TonChainAdapter (the loop handling response.jetton_transfers and using
addressesMatch, toAssetId, and TransferType) to catch the error as a variable
and log a clear contextual error (include txHash and pubkey and the error/stack)
via the adapter logger (e.g., this.logger.error or existing logging facility)
before returning [] so failures are recorded for debugging.
- Around line 960-963: The parseTx method currently coerces non-string inputs to
"[object Object]" causing API failures; update parseTx to either accept only
string hashes by changing its signature to parseTx(txHash: string, pubkey:
string): Promise<Transaction> and remove the fallback conversion, or add an
explicit type guard branch for TonTx objects (e.g., detect TonTx and extract its
hash or required fields) similar to the TRON/SUI pattern; modify the function
body around parseTx and any callers to pass a string hash (or handle TonTx) and
ensure types Transaction and TonTx are used consistently.
- Around line 891-893: The code lowercases addresses when comparing
tx.in_msg.destination, tx.in_msg.source, and pubkey which corrupts user-friendly
base64 TON addresses; update the normalization used by addressesMatch (or the
caller) so only raw TON addresses (e.g., addresses that start with "0:" or are
hex/raw forms) are converted to lowercase, while base64/user-friendly addresses
are left unchanged; implement this by adding a small discriminator (raw-address
pattern vs base64 pattern) and applying .toLowerCase() only for the raw path
before comparing in addressesMatch.
…n-t-parsing-txs-properly-


Description
Fixes the TON tx parsing upserted into history, which wasn't working at all previously
Issue (if applicable)
closes #
Risk
Testing
Engineering
Operations
Screenshots (if applicable)
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.