Skip to content

Fix TON transaction status from traces#1111

Merged
gemcoder21 merged 9 commits into
mainfrom
h/ton-tx-status-fix
May 12, 2026
Merged

Fix TON transaction status from traces#1111
gemcoder21 merged 9 commits into
mainfrom
h/ton-tx-status-fix

Conversation

@0xh3rman
Copy link
Copy Markdown
Collaborator

@0xh3rman 0xh3rman commented May 6, 2026

Summary

  • Fetch TON traces by inbound message hash when checking transaction status.
  • Map incomplete traces to pending and failed trace actions to reverted.
  • Keep the existing root transaction fee update from transactionsByMessage.
  • Add a real failed STON.fi USDT -> TON swap fixture where the root wallet transaction succeeds but a child trace action fails.

Validation

  • cargo fmt --all --check
  • cargo test -p gem_ton --features rpc provider::transaction_state_mapper::tests
  • cargo clippy -p gem_ton --features rpc --all-targets -- -D warnings

Note

  • This PR targets h/ton-stonfi-swap-fixes so the diff only contains the tx-status fix. Retarget to main after the swap PR lands.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request integrates TON traces into the transaction status logic to improve state accuracy. It adds new trace models, implements an RPC method to fetch traces, and updates the mapping logic to derive transaction states from trace actions. A review comment suggests optimizing the trace action iteration in the map_trace_state function to improve efficiency.

Comment thread crates/gem_ton/src/provider/transaction_state_mapper.rs Outdated
@0xh3rman 0xh3rman marked this pull request as draft May 7, 2026 05:49
@0xh3rman 0xh3rman force-pushed the h/ton-stonfi-swap-fixes branch from fcbb3a0 to 9cdf81c Compare May 7, 2026 05:51
@0xh3rman 0xh3rman force-pushed the h/ton-stonfi-swap-fixes branch 2 times, most recently from 2ae8ef5 to d0f63f6 Compare May 7, 2026 07:04
@0xh3rman 0xh3rman force-pushed the h/ton-tx-status-fix branch 3 times, most recently from 1109628 to 49f73e7 Compare May 7, 2026 10:11
@0xh3rman 0xh3rman marked this pull request as ready for review May 7, 2026 10:11
Base automatically changed from h/ton-stonfi-swap-fixes to main May 7, 2026 10:57
@0xh3rman 0xh3rman force-pushed the h/ton-tx-status-fix branch from 49f73e7 to fcacdd0 Compare May 7, 2026 12:04
0xh3rman and others added 8 commits May 8, 2026 11:25
Switch get_transactions_by_address, get_transaction_by_hash, and
get_transactions_by_block to /api/v3/traces, emit one Transaction per
trace (the root), and base64-decode the on-chain hash to hex so it
matches what every other chain stores and what Tonscan/Tonviewer expect.
Dedupes the activity feed (one row per swap instead of one per
internal jetton-wallet hop) and aligns with the broadcast hash format
already produced by map_transaction_broadcast.
get_transaction_by_hash now queries /api/v3/traces?tx_hash= so that
callers (e.g. /v1/chain/transactions/ton/<hash>) can pass the actual
transaction hash users see on Tonscan/Tonviewer. msg_hash is still used
for get_transaction_status since that path tracks the inbound external
message returned by the broadcast endpoint.
Wire ChainTransactionState through ChainProviders and ChainClient so
the API can return the provider's TransactionUpdate (state + fee/block
changes) for a given hash, e.g. to confirm or fail an in-flight TON
swap via traces.
Single helper that accepts either the inbound message hash from
broadcast or the on-chain transaction hash from an explorer. Used by
both get_transaction_status and get_transaction_by_hash so the two
call sites do not duplicate fallback logic.
@gemcoder21 gemcoder21 merged commit 24183ca into main May 12, 2026
6 checks passed
@gemcoder21 gemcoder21 deleted the h/ton-tx-status-fix branch May 12, 2026 23: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.

2 participants