Skip to content

Conversation

@rodrigopavezi
Copy link
Member

@rodrigopavezi rodrigopavezi commented Jan 26, 2026

Description of the changes

Added support for TRON blockchain payment detection in the Request Network. This implementation includes:

  • Created a TRON-specific ERC20 fee proxy payment detector (TronERC20FeeProxyPaymentDetector)
  • Added a TRON info retriever (TronInfoRetriever) to fetch payment events from TRON subgraphs
  • Integrated GraphQL queries for TRON payments with support for both mainnet and Nile testnet
  • Updated TheGraph client to support TRON chains
  • Added codegen configuration for TRON GraphQL schema
  • Registered TRON payment detectors in the payment network factory
  • Added comprehensive unit tests for the new TRON components

The implementation follows the same pattern as other blockchain integrations while accounting for TRON-specific requirements.


Closes RequestNetwork/private-issues#227

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

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.

Copy link
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 26, 2026

Greptile Overview

Greptile Summary

This PR adds comprehensive support for TRON blockchain payment detection to the Request Network. The implementation follows the established architectural patterns used for EVM and NEAR chains.

Key Changes:

  • Created TronERC20FeeProxyPaymentDetector that extends the base ERC20 fee proxy detector for TRON-specific payment detection
  • Implemented TronInfoRetriever to fetch payment events from TRON subgraphs using GraphQL queries
  • Integrated TRON support into TheGraphClient with dedicated SDK (getTronSdk) and subgraph URLs for both mainnet and Nile testnet
  • Registered TRON payment detectors in the PaymentNetworkFactory for both tron and nile network chains
  • Added GraphQL queries supporting both token-filtered and any-token payment retrieval
  • Configured GraphQL code generation pipeline for TRON schema
  • Included comprehensive unit tests achieving good coverage of core functionality

Implementation Quality:
The code follows consistent patterns from existing NEAR/EVM implementations, properly handles network validation, error cases, and edge conditions. The test coverage validates deployment information, network validation, and event extraction flows.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation follows established patterns from NEAR/EVM integrations, includes comprehensive unit tests, proper error handling, and network validation. The code is well-structured, maintainable, and integrates cleanly with existing architecture.
  • No files require special attention

Important Files Changed

Filename Overview
packages/payment-detection/src/tron/tron-fee-proxy-detector.ts New TRON ERC20 fee proxy payment detector following established patterns from EVM/NEAR detectors
packages/payment-detection/src/tron/tron-info-retriever.ts TheGraph-based info retriever for TRON payments with proper event mapping
packages/payment-detection/src/thegraph/client.ts Added TRON chain support with dedicated SDK and subgraph URLs for mainnet and Nile testnet
packages/payment-detection/src/payment-network-factory.ts Registered TRON ERC20 fee proxy detector for both tron and nile networks
packages/payment-detection/src/thegraph/queries/tron/GetTronPayments.graphql GraphQL queries for TRON payment events with and without token filtering

Sequence Diagram

sequenceDiagram
    participant Client
    participant Factory as PaymentNetworkFactory
    participant Detector as TronERC20FeeProxyPaymentDetector
    participant Retriever as TronInfoRetriever
    participant GraphQL as TheGraphClient<TronChain>
    participant Subgraph as TRON Subgraph

    Client->>Factory: getPaymentNetworkFromRequest(request)
    Factory->>Factory: Identify TRON chain (tron/nile)
    Factory->>Detector: new TronERC20FeeProxyPaymentDetector({network, getSubgraphClient})
    Factory-->>Client: Return detector instance

    Client->>Detector: extractEvents(eventName, toAddress, paymentReference, currency, chain)
    Detector->>Detector: Validate TRON chain support
    Detector->>Detector: Validate network matches detector network
    Detector->>Detector: getDeploymentInformation(chain)
    Note over Detector: Gets proxy contract address & creation block

    Detector->>Detector: getSubgraphClient(chain)
    Note over Detector: Returns TheGraphClient for tron/nile
    
    Detector->>Retriever: new TronInfoRetriever(subgraphClient)
    Detector->>Retriever: getTransferEvents({paymentReference, toAddress, contractAddress, acceptedTokens})

    Retriever->>Retriever: Hash payment reference with keccak256
    
    alt Single token filter
        Retriever->>GraphQL: GetTronPayments(reference, to, tokenAddress, contractAddress)
    else No token filter
        Retriever->>GraphQL: GetTronPaymentsAnyToken(reference, to, contractAddress)
    end

    GraphQL->>Subgraph: Query payment events
    Subgraph-->>GraphQL: Return payments array
    GraphQL-->>Retriever: Return payments

    Retriever->>Retriever: Map payments to event format
    Note over Retriever: Convert amount, feeAmount to strings<br/>Add txHash, block, timestamp

    Retriever-->>Detector: Return {paymentEvents}
    Detector-->>Client: Return payment events
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch from 853297e to 5bb6ef7 Compare January 27, 2026 01:49
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch from 5bb6ef7 to 3c7d77f Compare January 27, 2026 01:53
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch 2 times, most recently from 816af51 to fc1128c Compare January 27, 2026 01:58
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch from fc1128c to cf070e9 Compare January 27, 2026 02:02
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch 2 times, most recently from 62f2685 to 3bf2428 Compare January 27, 2026 02:25
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-currency branch 2 times, most recently from d515038 to 6e1a893 Compare January 27, 2026 02:34
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch from 3bf2428 to f06892c Compare January 27, 2026 02:34
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch from f06892c to 8456f0a Compare January 27, 2026 02:39
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch 2 times, most recently from 720a911 to 9c63452 Compare January 27, 2026 08:43
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch from 4770f6a to f39a087 Compare January 27, 2026 09:04
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch from 6631746 to e0785a2 Compare January 27, 2026 09:16
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-currency branch 2 times, most recently from 62d10a1 to 2496888 Compare January 27, 2026 09:29
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch from e0785a2 to 2319127 Compare January 27, 2026 09:29
- Add TronFeeProxyDetector for detecting Tron payments
- Add TronInfoRetriever for fetching payment data from TheGraph
- Add GraphQL queries for Tron payments
- Integrate Tron detector into payment network factory
- Add unit tests for detector and retriever
- Add schema.graphql to payment-detection package for TRON types
- Update codegen-tron.yml to use local schema instead of substreams
- Remove conditional codegen script (schema is now always available)
- Fix TronERC20FeeProxyPaymentDetector static method signature
- Add explicit type annotation in tron-info-retriever
- Add contractVersion to getDeploymentInformation return type
- Update getTheGraphInfoRetriever to accept TronChainName clients
@rodrigopavezi rodrigopavezi force-pushed the feat/tron-payment-detection branch from 2319127 to cecfc7e Compare January 28, 2026 14:50
MantisClone

This comment was marked as duplicate.

Copy link
Member

@MantisClone MantisClone left a comment

Choose a reason for hiding this comment

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

Looks good to me so far.

Reviewed with Claude Code Opus 4.5

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.

3 participants