-
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
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
720a911 to
9c63452
Compare
60d3c03 to
d0a6207
Compare
d0a6207 to
13b2632
Compare
13b2632 to
c5a8b72
Compare
4770f6a to
f39a087
Compare
c5a8b72 to
96fe3e0
Compare
6631746 to
e0785a2
Compare
19beedb to
f8bb525
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.
f8bb525 to
ceec59f
Compare
2319127 to
cecfc7e
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