Skip to content

feat: add Tron payment detection retrievers and advanced logic support - #1691

Merged
rodrigopavezi merged 24 commits into
masterfrom
feat/tron-substreams
Feb 12, 2026
Merged

feat: add Tron payment detection retrievers and advanced logic support#1691
rodrigopavezi merged 24 commits into
masterfrom
feat/tron-substreams

Conversation

@rodrigopavezi

@rodrigopavezirodrigopavezi commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Description of the changes

Added a new Substreams module for indexing ERC20FeeProxy payment events on the TRON blockchain. This module:

  • Tracks TransferWithReferenceAndFee events from deployed ERC20FeeProxy contracts on TRON mainnet and Nile testnet
  • Extracts payment details including token address, amount, recipient, payment reference, fee information, and transaction metadata
  • Provides a Rust implementation with WASM compilation for Substreams
  • Includes configuration for deployment as a Substreams-powered subgraph
  • Contains Makefile, build scripts, and package configuration for easy development and deployment
  • Implements Base58 encoding for TRON addresses
  • Supports both mainnet (TCUDPYnS9dH3WvFEaE7wN7vnDa51J4R4fd) and Nile testnet (THK5rNmrvCujhmrXa5DB1dASepwXTr9cJs) contract addresses

Closes RequestNetwork/private-issues#226

@coderabbitai

coderabbitaiBot commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@rodrigopavezi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 17 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

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

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.

@rodrigopavezirodrigopavezi self-assigned this Jan 26, 2026
@rodrigopavezi
rodrigopavezi marked this pull request as ready for review January 26, 2026 14:56
@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR adds a new Substreams module for indexing ERC20FeeProxy payment events on TRON blockchain (mainnet and Nile testnet). The implementation includes Rust code to parse TransferWithReferenceAndFee events, protobuf definitions, GraphQL schema, and deployment configurations.

Critical Issues Found:

  • Missing bs58 dependency in Cargo.toml - code will not compile
  • Event signature hash is incomplete (40 chars vs 64) AND never validated in the filtering logic, causing the parser to attempt processing ALL events from proxy contracts instead of just TransferWithReferenceAndFee events
  • Missing src/mappings.ts file referenced in subgraph.yaml - subgraph deployment will fail
  • store_payments module declared in substreams.yaml but no corresponding handler function implemented

Positive Aspects:

  • Well-structured protobuf definitions and GraphQL schema
  • Comprehensive README with clear documentation
  • Proper Base58Check encoding implementation for TRON addresses
  • Good separation of concerns with modular parsing functions

Confidence Score: 0/5

  • This PR has critical build and logic errors that will prevent compilation and correct operation
  • Multiple blocking issues: missing dependency will cause build failure, incorrect event validation will process wrong events, missing required file will block deployment, and undefined handler will cause runtime errors
  • Critical attention needed for Cargo.toml, src/lib.rs, subgraph.yaml, and substreams.yaml - all have blocking issues that must be resolved before merge

Important Files Changed

FilenameOverview
packages/substreams-tron/Cargo.tomlMissing critical bs58 dependency - build will fail
packages/substreams-tron/src/lib.rsCritical logic errors: incorrect event signature, no event validation, will parse wrong events
packages/substreams-tron/substreams.yamlDefines store_payments module without implementation handler
packages/substreams-tron/subgraph.yamlReferences non-existent mappings.ts file - deployment will fail

Sequence Diagram

sequenceDiagram
participant TB as TRON Blockchain
participant SS as Substreams Module
participant Map as map_erc20_fee_proxy_payments
participant Parser as Event Parser
participant Store as store_payments
participant SG as Subgraph (mappings.ts)
TB->>SS: Block Stream (sf.tron.type.v1.Block)
SS->>Map: Process Block
loop For each transaction
Map->>Map: Extract transaction logs
loop For each log entry
Map->>Map: Check contract address<br/>(MAINNET or NILE proxy)
alt Contract address matches
Map->>Parser: parse_transfer_with_reference_and_fee()
Parser->>Parser: Extract payment reference from topics[1]
Parser->>Parser: Parse ABI-encoded data:<br/>- token_address<br/>- to<br/>- amount<br/>- fee_amount<br/>- fee_address
Parser->>Parser: Extract sender from transaction
Parser->>Parser: base58_encode() addresses
Parser-->>Map: Payment object
Map->>Map: Add to payments collection
end
end
end
Map-->>Store: Payments (proto:request.tron.v1.Payments)
Store->>Store: Index by payment reference
Store-->>SG: Payment events
SG->>SG: Transform to GraphQL entities
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

4 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Comment threadpackages/substreams-tron/Cargo.toml Outdated
Comment threadpackages/substreams-tron/src/lib.rs Outdated
Comment threadpackages/substreams-tron/subgraph.yaml Outdated
Comment threadpackages/substreams-tron/substreams.yaml Outdated
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from 7928566 to 5ac332aCompareJanuary 27, 2026 01:49
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from 5ac332a to 984a642CompareJanuary 27, 2026 01:53
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch 2 times, most recently from 41e33e8 to d03f1dbCompareJanuary 27, 2026 01:58
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-substreams branch 2 times, most recently from cc6dc3b to 5775865CompareJanuary 27, 2026 02:02
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch 2 times, most recently from 7d73139 to 6dce563CompareJanuary 27, 2026 02:15
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from 6dce563 to dbed330CompareJanuary 27, 2026 02:25
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-substreams branch 2 times, most recently from 0d5df81 to 55ba0a1CompareJanuary 27, 2026 02:34
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch 2 times, most recently from 1797a69 to d5e25dfCompareJanuary 27, 2026 02:39
@rodrigopavezi
rodrigopaveziforce-pushed the feat/tron-payment-processor branch from d5e25df to b5ce760CompareJanuary 27, 2026 02:45
@rodrigopaveziGraphite App

rodrigopavezi commented Feb 12, 2026

Copy link
Copy Markdown
ContributorAuthor

Merge activity

  • Feb 12, 1:06 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 12, 1:17 PM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 12, 1:18 PM UTC: @rodrigopavezi merged this pull request with Graphite.

@rodrigopavezi
rodrigopavezi changed the base branch from feat/tron-payment-processor to graphite-base/1691February 12, 2026 13:14
@rodrigopavezi
rodrigopavezi changed the base branch from graphite-base/1691 to masterFebruary 12, 2026 13:15
- Add substreams configuration for Tron payment indexing
- Add protobuf definitions and schema
- Add Rust implementation for payment extraction
- Fix truncated TRANSFER_WITH_REF_AND_FEE_TOPIC (was 40 chars, now 64 chars)
- Add validation to check topics[0] matches expected event signature
- Prevents parsing non-TransferWithReferenceAndFee events
- Add hexAddress to deployment files (mainnet.json and nile.json)
- Move tron/nile chain definitions from declarative to tron folder
- Update DeclarativeChainName type to remove tron/nile
- Use erc20FeeProxyArtifact.getDeploymentInformation() instead of hardcoded values
- Rename tron-fee-proxy.ts to trc20-fee-proxy.ts for clarity
- Make fee limit configurable in utils-tron.ts with defaults
- Remove hardcoded MAINNET_PROXY_ADDRESS and NILE_PROXY_ADDRESS constants
- Add parse_proxy_addresses function to read addresses from params
- Update substreams.yaml to pass params to the map module
This allows the proxy addresses to be configured without recompiling.
Proto package directory mismatch:
- Move payments.proto to proto/request/tron/v1/ to match package declaration
- Update build.rs and substreams.yaml with new path
Transaction success validation:
- Add TronTransactionInfo interface
- Add getTransactionInfo method to TronWeb interface
- Add waitForTransactionConfirmation helper function
- Add optional waitForConfirmation parameter to approveTrc20 and processTronFeeProxyPayment
- Add missing bs58 dependency to Cargo.toml
- Fix subgraph.yaml to use correct substreams/graph-entities pattern
- Remove store_payments module (no handler implemented)
- Add dedicated build-substreams-tron job with Rust 1.75 image
- Install wasm32-unknown-unknown target for WebAssembly compilation
- Add cargo caching for faster builds
- Run tests as part of the CI job
- Update package.json to skip lerna build (requires Rust toolchain)
… crate
The substreams-tron crate doesn't exist on crates.io. Instead, we now
include pre-generated protobuf types from the StreamingFast tron-foundational
module. This includes:
- sf.tron.type.v1 types (Block, Transaction, etc.)
- protocol types (TransactionInfo, Log, Contract, etc.)
- request.tron.v1 types (Payment, Payments)
Also fixed type references in lib.rs to use the correct Transaction
structure instead of the non-existent TransactionTrace.
The home crate v0.5.12 requires Rust edition 2024 which was
stabilized in Rust 1.85.
substreams v0.5.22 uses prost v0.11.9, so we need to use the same
version to avoid trait incompatibility errors.
- Add engines, bugs, and homepage fields
- Add period at end of description
- Reorder properties with description after private
The substreams-tron tests require Rust/cargo which is only available
in the dedicated build-substreams-tron CI job, not the general
Node.js test environment.
The test was importing from 'tron-fee-proxy' but the source file
is named 'trc20-fee-proxy.ts'.
- Remove packages/substreams-tron (moved to payments-substream/tron)
- Remove build-substreams-tron job from CircleCI config
- Update graphql.config.yml to use local schema
- Substreams now maintained in separate repo for cleaner separation
The Sepolia subgraph no longer exists on The Graph Studio, causing
GraphQL code generation to fail during builds.
- Use TronFeeProxyPaymentDetector naming
- Include Hasura client exports for substreams integration
- Add HasuraClient to query payment data from substreams-powered Hasura
- Add TronInfoRetriever using Hasura instead of TheGraph
- Update TronFeeProxyPaymentDetector to use Hasura client
- Add tests for HasuraClient and payment network factory
…raClient
- Delete TronInfoRetriever implementation as it is no longer used.
- Enhance HasuraClient to support JWT authentication and roles.
- Update tests for HasuraClient and TronInfoRetriever to reflect changes in structure and functionality.
…suraClient
- Introduce TronTheGraphInfoRetriever for TRON-specific payment detection using The Graph.
- Update ERC20FeeProxyPaymentDetector to support TRON chain.
- Modify HasuraClient to utilize GraphQL variables for improved query safety.
- Add tests to validate new functionality and ensure correct usage of GraphQL variables.
- Correct the import path for TronTheGraphInfoRetriever to reflect its new location in the retrievers directory.
…ss validation
- Enhance address validation logic to accept TRON Base58 addresses, which start with 'T' and are 34 characters long.
… fee proxy
- Introduce a method to validate TRON Base58 addresses in AddressBasedPaymentNetwork.
- Update Erc20FeeProxyPaymentNetwork to handle TRON addresses correctly.
- Add tests to ensure TRON address validation works as expected and does not interfere with other currency types.
…tector with Hasura client mock
- Mock the Hasura client to control its return value in tests.
- Update tests to check for errors when the Hasura client is unavailable.
- Remove unused mock subgraph client references to streamline the test setup.
@rodrigopavezi
rodrigopavezi merged commit f49d003 into masterFeb 12, 2026
5 of 7 checks passed
@rodrigopavezirodrigopavezi mentioned this pull request Feb 16, 2026
Sign up for freeto 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.

3 participants

@rodrigopavezi@MantisClone@aimen74