-
Notifications
You must be signed in to change notification settings - Fork 92
feat: add Tron payment processor support #1690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/tron-payment-detection
Are you sure you want to change the base?
feat: add Tron payment processor support #1690
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Greptile OverviewGreptile SummaryAdded comprehensive Tron blockchain payment support to the payment-processor package, enabling TRC20 token payments through the ERC20 Fee Proxy contract. Key Changes:
Implementation Details:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant TronFeeProxy as tron-fee-proxy.ts
participant UtilsTron as utils-tron.ts
participant TronWeb
participant TRC20Contract as TRC20 Token
participant ProxyContract as ERC20FeeProxy
Note over Client,ProxyContract: Approval Flow
Client->>TronFeeProxy: approveTronFeeProxyRequest(request, tronWeb)
TronFeeProxy->>TronFeeProxy: Validate network (TronChains)
TronFeeProxy->>TronFeeProxy: Calculate total amount (payment + fee)
TronFeeProxy->>UtilsTron: approveTrc20(tronWeb, tokenAddress, network, amount)
UtilsTron->>UtilsTron: getERC20FeeProxyAddress(network)
UtilsTron->>TronWeb: contract(TRC20_ABI, tokenAddress)
TronWeb-->>UtilsTron: TRC20 contract instance
UtilsTron->>TRC20Contract: approve(proxyAddress, amount).send()
TRC20Contract-->>UtilsTron: Transaction result
UtilsTron->>UtilsTron: callback.onHash(txHash)
UtilsTron-->>TronFeeProxy: txHash
TronFeeProxy-->>Client: txHash
Note over Client,ProxyContract: Payment Flow
Client->>TronFeeProxy: payTronFeeProxyRequest(request, tronWeb)
TronFeeProxy->>TronFeeProxy: Validate network (TronChains)
TronFeeProxy->>TronFeeProxy: validateRequest(ERC20_FEE_PROXY_CONTRACT)
TronFeeProxy->>TronFeeProxy: getRequestPaymentValues()
TronFeeProxy->>TronFeeProxy: validatePaymentReference()
TronFeeProxy->>UtilsTron: isValidTronAddress(paymentAddress)
UtilsTron-->>TronFeeProxy: validation result
TronFeeProxy->>UtilsTron: getTronAllowance(tronWeb, tokenAddress, network)
UtilsTron->>TronWeb: contract(TRC20_ABI, tokenAddress)
TronWeb-->>UtilsTron: contract instance
UtilsTron->>TRC20Contract: allowance(owner, spender).call()
TRC20Contract-->>UtilsTron: allowance amount
UtilsTron-->>TronFeeProxy: BigNumber allowance
alt Insufficient Allowance
TronFeeProxy-->>Client: Error: Insufficient TRC20 allowance
end
TronFeeProxy->>UtilsTron: isTronAccountSolvent(tronWeb, tokenAddress, amount)
UtilsTron->>TronWeb: contract(TRC20_ABI, tokenAddress)
TronWeb-->>UtilsTron: contract instance
UtilsTron->>TRC20Contract: balanceOf(owner).call()
TRC20Contract-->>UtilsTron: balance
UtilsTron-->>TronFeeProxy: true/false
alt Insufficient Balance
TronFeeProxy-->>Client: Error: Insufficient TRC20 token balance
end
TronFeeProxy->>UtilsTron: processTronFeeProxyPayment(params)
UtilsTron->>UtilsTron: Validate all addresses
UtilsTron->>UtilsTron: getERC20FeeProxyAddress(network)
UtilsTron->>TronWeb: contract(ERC20_FEE_PROXY_ABI, proxyAddress)
TronWeb-->>UtilsTron: proxy contract instance
UtilsTron->>UtilsTron: Format payment reference (add 0x prefix)
UtilsTron->>ProxyContract: transferFromWithReferenceAndFee(token, to, amount, ref, feeAmount, feeAddress).send()
ProxyContract->>TRC20Contract: transferFrom(payer, recipient, amount)
TRC20Contract-->>ProxyContract: success
alt Fee > 0
ProxyContract->>TRC20Contract: transferFrom(payer, feeRecipient, feeAmount)
TRC20Contract-->>ProxyContract: success
end
ProxyContract-->>UtilsTron: Transaction result
UtilsTron->>UtilsTron: callback.onHash(txHash)
UtilsTron-->>TronFeeProxy: txHash
TronFeeProxy-->>Client: txHash
|
There was a problem hiding this 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
853297e to
5bb6ef7
Compare
5ac332a to
984a642
Compare
3c7d77f to
816af51
Compare
984a642 to
41e33e8
Compare
816af51 to
fc1128c
Compare
41e33e8 to
d03f1db
Compare
fc1128c to
cf070e9
Compare
d03f1db to
7d73139
Compare
cf070e9 to
62f2685
Compare
6dce563 to
dbed330
Compare
3bf2428 to
f06892c
Compare
1797a69 to
d5e25df
Compare
f06892c to
8456f0a
Compare
b5ce760 to
60d3c03
Compare
f8bb525 to
ceec59f
Compare
2319127 to
cecfc7e
Compare
MantisClone
left a comment
There was a problem hiding this 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
MantisClone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM — well-typed TronWeb interface, good validation (address format, balance, allowance). One minor non-blocking comment about fee limits (see inline).
cecfc7e to
6c8cb20
Compare
ceec59f to
10ddce5
Compare
6c8cb20 to
938afca
Compare
10ddce5 to
362dbbc
Compare
938afca to
c8c4b67
Compare
5ec56fe to
b8f3840
Compare
b8f3840 to
55c4451
Compare
1408a38 to
559e872
Compare
55c4451 to
2d1ffbc
Compare
559e872 to
96f878e
Compare
7f462e4 to
91553a4
Compare
- Add tron-fee-proxy payment functions - Add Tron utility functions for transaction handling - Add unit tests for Tron payment processing - Update request-client tests for Tron support
Add a retry loop to wait for the Graph node to be ready on port 8020 before attempting to create and deploy the subgraph.
- Introduce DEFAULT_TRON_APPROVAL_FEE_LIMIT and DEFAULT_TRON_PAYMENT_FEE_LIMIT constants for TRC20 transactions. - Update approveTrc20 and processTronFeeProxyPayment functions to use dynamic fee limits instead of hardcoded values.
- Update ERC20FeeProxyPaymentDetector to support TronChainName by adding TronInfoRetriever. - Enhance the getTheGraphInfoRetriever method to handle Tron payment chains.
- Change import statement for TronInfoRetriever to reflect new file structure in the tron directory.
91553a4 to
8315931
Compare
96f878e to
35cc88d
Compare

Description of the changes
Added support for Tron blockchain payments in the payment-processor package. This implementation enables TRC20 token payments through the ERC20 Fee Proxy contract on Tron networks.
The changes include:
New
tron-fee-proxy.tsmodule with functions for paying requests on Tron:payTronFeeProxyRequest- Process payments with TRC20 tokensapproveTronFeeProxyRequest- Approve token spendinghasSufficientTronAllowance- Check token allowancehasSufficientTronBalance- Verify token balancegetTronPaymentInfo- Get payment detailsNew
utils-tron.tsmodule with Tron-specific utilities:Comprehensive test coverage for all new functionality
Exports for the new modules in the package index
Closes RequestNetwork/private-issues#234