-
Notifications
You must be signed in to change notification settings - Fork 92
add tron support for smart contracts and payment processor #1684
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: master
Are you sure you want to change the base?
add tron support for smart contracts and payment processor #1684
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (39)
WalkthroughAdds Tron blockchain support: chain definitions, Tron-aware types, Tron smart contracts (ERC20FeeProxy and TRC20 variants), deployment/migration scripts, Tron utilities and payment-processor integrations, tests, artifacts, documentation, and a CI workflow for compiling Tron contracts. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant PaymentProcessor
participant TronWeb
participant ERC20FeeProxy as ERC20FeeProxy<br/>(Contract)
participant Token as TestTRC20<br/>(Token)
Client->>PaymentProcessor: payTronFeeProxyRequest(request, amount, feeAmount)
PaymentProcessor->>TronWeb: validate network & format data
PaymentProcessor->>Token: getAllowance(payer, proxy)
Token-->>PaymentProcessor: allowance
PaymentProcessor->>Token: getBalance(payer)
Token-->>PaymentProcessor: balance
PaymentProcessor->>TronWeb: ensure allowance & balance
PaymentProcessor->>ERC20FeeProxy: transferFromWithReferenceAndFee(token, to, amount, reference, feeAmount, feeAddress)
ERC20FeeProxy->>Token: transferFrom(payer, to, amount)
Token-->>ERC20FeeProxy: success/failure
ERC20FeeProxy->>Token: transferFrom(payer, feeAddress, feeAmount) (if feeAmount>0)
Token-->>ERC20FeeProxy: success/failure
ERC20FeeProxy->>TronWeb: txHash / receipt
TronWeb-->>PaymentProcessor: txHash/confirmation
PaymentProcessor-->>Client: return txHash / result
sequenceDiagram
participant Client
participant PaymentProcessor
participant TronWeb
participant Token as TestTRC20<br/>(Token)
Client->>PaymentProcessor: approveTronFeeProxyRequest(request, amount)
PaymentProcessor->>TronWeb: validate request & compute totalAmount
PaymentProcessor->>Token: approve(proxyAddress, totalAmount)
Token-->>PaymentProcessor: txHash / approval confirmed
PaymentProcessor-->>Client: return approval txHash
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
1946425 to
74afb66
Compare
Greptile SummaryThis PR adds comprehensive Tron blockchain support to Request Network, enabling TRC20 token payments through the Key Changes
Implementation QualityThe implementation demonstrates strong engineering practices:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as User/Payer
participant TronWeb as TronWeb
participant PaymentProcessor as Payment Processor
participant TRC20 as TRC20 Token
participant FeeProxy as ERC20FeeProxy Contract
participant Payee as Payment Recipient
participant FeeRecipient as Fee Recipient
User->>PaymentProcessor: payTronFeeProxyRequest(request, tronWeb)
PaymentProcessor->>PaymentProcessor: validateRequest()
PaymentProcessor->>PaymentProcessor: getTronPaymentInfo()
Note over PaymentProcessor: Check allowance and balance
PaymentProcessor->>TronWeb: getTronAllowance(tokenAddress, network)
TronWeb->>TRC20: allowance(payer, proxyAddress)
TRC20-->>TronWeb: currentAllowance
TronWeb-->>PaymentProcessor: currentAllowance
alt Insufficient Allowance
PaymentProcessor-->>User: Error: Insufficient allowance
User->>PaymentProcessor: approveTronFeeProxyRequest(request, tronWeb)
PaymentProcessor->>TronWeb: approveTrc20(tokenAddress, network, amount)
TronWeb->>TRC20: approve(proxyAddress, amount)
TRC20-->>TronWeb: txHash
TronWeb-->>PaymentProcessor: txHash
PaymentProcessor-->>User: Approval txHash
end
PaymentProcessor->>TronWeb: isTronAccountSolvent(tokenAddress, totalAmount)
TronWeb->>TRC20: balanceOf(payer)
TRC20-->>TronWeb: balance
TronWeb-->>PaymentProcessor: hasSufficientBalance
alt Insufficient Balance
PaymentProcessor-->>User: Error: Insufficient balance
end
Note over PaymentProcessor: Process payment
PaymentProcessor->>TronWeb: processTronFeeProxyPayment()
TronWeb->>FeeProxy: transferFromWithReferenceAndFee(tokenAddress, payee, amount, reference, feeAmount, feeAddress)
Note over FeeProxy: Execute transfers
FeeProxy->>TRC20: transferFrom(payer, payee, amount)
TRC20->>Payee: Transfer payment amount
TRC20-->>FeeProxy: success
alt Fee Amount > 0
FeeProxy->>TRC20: transferFrom(payer, feeRecipient, feeAmount)
TRC20->>FeeRecipient: Transfer fee amount
TRC20-->>FeeProxy: success
end
FeeProxy->>FeeProxy: emit TransferWithReferenceAndFee()
FeeProxy-->>TronWeb: txHash
TronWeb-->>PaymentProcessor: txHash
PaymentProcessor-->>User: Payment txHash
|
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
74afb66 to
bfd7e2f
Compare
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
bfd7e2f to
bf7961e
Compare
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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@packages/smart-contracts/tron/deployments/mainnet.json`:
- Around line 8-11: The ERC20FeeProxy entry currently has hexAddress set to
"TO_BE_FILLED"; update the ERC20FeeProxy object so hexAddress contains the
correct Tron hex address (the 41... format) that corresponds to address
"TCUDPYnS9dH3WvFEaE7wN7vnDa51J4R4fd", or if that field is unused remove the
hexAddress key entirely; locate the ERC20FeeProxy block in the JSON (the object
with "address", "hexAddress", "creationBlockNumber") and either replace
"TO_BE_FILLED" with the actual 41-prefixed hex address or delete the hexAddress
property to avoid runtime resolution failures.
In `@packages/smart-contracts/tron/deployments/nile.json`:
- Around line 9-11: Replace the incorrect hexAddress value for the deployment
entry that has address "THK5rNmrvCujhmrXa5DB1dASepwXTr9cJs": update the
"hexAddress" field from "414b8e0e0d4c9ec8a8f3f4a5b6c7d8e9f0a1b2c3d4" to the
correct hex derived from the base58 address —
"41508B3B4059C40BB3AAC5DA5AC006CCDD9C4DC957" so the JSON entry's "hexAddress"
matches the "address" and prevents runtime contract interaction failures.
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
bf7961e to
a990789
Compare
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
a990789 to
6ff88e8
Compare
6ff88e8 to
5d88414
Compare
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
1 similar comment
✅ Slither Security AnalysisStatus: Passed Findings Summary
📄 Full report available in workflow artifacts. |
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|
1 similar comment
✅ Echidna Fuzzing ResultsMode: ci (50000 test sequences) Property Test Results
📄 Full report and corpus available in workflow artifacts. ℹ️ About Echidna FuzzingEchidna is a property-based fuzzer that generates random sequences of transactions Properties tested:
|

Add Tron Blockchain Support for Smart Contracts and Payment Processor
Summary
This PR adds comprehensive Tron blockchain support to Request Network, enabling TRC20 token payments through the
ERC20FeeProxycontract. The implementation includes smart contract deployment infrastructure, a new payment processor module, and a complete test suite to ensure feature parity with EVM chains.Problem Statement
No payment proxy contract existed on Tron, blocking all payment functionality for Tron users. This PR resolves this by deploying the
ERC20FeeProxycontract adapted for TRC20 tokens.Changes
Smart Contracts (
packages/smart-contracts)tronbox-config.jswith support for local development, Nile testnet, and mainnettron/contracts/directory with Solidity contracts compiled for Tron (solc 0.8.6)TestTRC20,BadTRC20,TRC20True,TRC20NoReturn,TRC20False,TRC20Revertfor comprehensive testingdeploy-nile.js- Deploy to Nile testnetdeploy-mainnet.js- Deploy to Tron mainnet (with safety confirmations)verify-deployment.js- Verify deployed contractssetup-test-wallet.js- Helper for test wallet setupERC20FeeProxyartifact with Tron deployment addresses:THK5rNmrvCujhmrXa5DB1dASepwXTr9cJsTCUDPYnS9dH3WvFEaE7wN7vnDa51J4R4fdPayment Processor (
packages/payment-processor)utils-tron.ts: TronWeb utilities for address validation, balance/allowance checks, and contract interactionstron-fee-proxy.ts: Payment functions for Tron:payTronFeeProxyRequest()- Execute TRC20 paymentsapproveTronFeeProxyRequest()- Approve token spendinghasSufficientTronAllowance()- Check allowancehasSufficientTronBalance()- Check balancegetTronPaymentInfo()- Get payment details from requestCurrency Package (
packages/currency)TronChainsclass for Tron chain utilitiesniletestnet chain definitiontronchain with TRC20 token informationTypes Package (
packages/types)TronChainNameto include'tron' | 'nile'VMChainNameto include Tron chainsCI/CD (
.github/workflows)tron-smart-contracts.yml: New workflow for Tron contract compilation and testingtronbox/treDocker image for local testingTest Coverage
Smart Contract Tests (
tron/test/ERC20FeeProxy.test.js)13 test cases matching EVM test coverage:
Payment Processor Tests (
test/payment/tron-fee-proxy.test.ts)21 unit tests covering:
New npm Scripts
yarn tron:compile # Compile Tron contracts
yarn tron:test # Run tests on local TRE
yarn tron:deploy:nile # Deploy to Nile testnet
yarn tron:deploy:mainnet # Deploy to mainnet
yarn tron:verify:nile # Verify Nile deployment
yarn tron:verify:mainnet # Verify mainnet deployment
yarn tron:setup-wallet # Setup test wallet
yarn tron:deploy:test-token # Deploy test token to Nile
Summary by CodeRabbit
New Features
Tests
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.