Skip to content

Commit eb28e46

Browse files
committed
reorg folders
1 parent 0324fff commit eb28e46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+58057
-11
lines changed
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: Tron Smart Contracts Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- 'packages/smart-contracts/tron/**'
9+
- 'packages/smart-contracts/tronbox-config.js'
10+
- 'packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/**'
11+
- 'packages/payment-processor/src/payment/*tron*'
12+
- 'packages/payment-processor/test/payment/*tron*'
13+
- 'packages/currency/src/chains/tron/**'
14+
- '.github/workflows/tron-smart-contracts.yml'
15+
push:
16+
branches:
17+
- master
18+
paths:
19+
- 'packages/smart-contracts/tron/**'
20+
- 'packages/smart-contracts/tronbox-config.js'
21+
- 'packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/**'
22+
- 'packages/payment-processor/src/payment/*tron*'
23+
- 'packages/payment-processor/test/payment/*tron*'
24+
- 'packages/currency/src/chains/tron/**'
25+
workflow_dispatch:
26+
27+
jobs:
28+
tron-compile-check:
29+
name: Tron Contract Compilation Check
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: '22'
40+
cache: 'yarn'
41+
42+
- name: Install TronBox globally
43+
run: npm install -g tronbox
44+
45+
- name: Install dependencies
46+
run: yarn install --frozen-lockfile
47+
48+
- name: Compile Tron contracts
49+
working-directory: packages/smart-contracts
50+
run: yarn tron:compile
51+
52+
- name: Verify build artifacts exist
53+
working-directory: packages/smart-contracts
54+
run: |
55+
echo "Checking build artifacts..."
56+
ls -la tron-build/
57+
58+
# Verify key contracts were compiled
59+
for contract in ERC20FeeProxy TestTRC20 BadTRC20 TRC20True TRC20NoReturn TRC20False TRC20Revert; do
60+
if [ ! -f "tron-build/${contract}.json" ]; then
61+
echo "ERROR: ${contract}.json not found!"
62+
exit 1
63+
fi
64+
echo "✓ ${contract}.json exists"
65+
done
66+
67+
echo "✅ All required artifacts present"
68+
69+
- name: Verify contract ABI structure
70+
working-directory: packages/smart-contracts
71+
run: |
72+
echo "Verifying ERC20FeeProxy ABI..."
73+
74+
# Check that the compiled contract has the expected functions
75+
for func in transferFromWithReferenceAndFee; do
76+
if ! grep -q "$func" tron-build/ERC20FeeProxy.json; then
77+
echo "ERROR: ERC20FeeProxy missing $func function!"
78+
exit 1
79+
fi
80+
echo "✓ ERC20FeeProxy has $func"
81+
done
82+
83+
# Verify TestTRC20 has standard ERC20 functions
84+
for func in transfer approve transferFrom balanceOf allowance; do
85+
if ! grep -q "$func" tron-build/TestTRC20.json; then
86+
echo "ERROR: TestTRC20 missing $func function!"
87+
exit 1
88+
fi
89+
echo "✓ TestTRC20 has $func"
90+
done
91+
92+
echo "✅ Contract ABI structure verified"
93+
94+
- name: Verify deployment files are valid JSON
95+
working-directory: packages/smart-contracts
96+
run: |
97+
echo "Validating deployment files..."
98+
99+
for network in nile mainnet; do
100+
file="tron/deployments/${network}.json"
101+
if [ -f "$file" ]; then
102+
if ! python3 -m json.tool "$file" > /dev/null 2>&1; then
103+
echo "ERROR: $file is not valid JSON!"
104+
exit 1
105+
fi
106+
107+
# Verify required fields
108+
if ! grep -q '"ERC20FeeProxy"' "$file"; then
109+
echo "ERROR: $file missing ERC20FeeProxy entry!"
110+
exit 1
111+
fi
112+
113+
if ! grep -q '"address"' "$file"; then
114+
echo "ERROR: $file missing address field!"
115+
exit 1
116+
fi
117+
118+
echo "✓ $file is valid"
119+
fi
120+
done
121+
122+
echo "✅ Deployment files validated"
123+
124+
tron-payment-processor-tests:
125+
name: Tron Payment Processor Unit Tests
126+
runs-on: ubuntu-latest
127+
128+
steps:
129+
- name: Checkout repository
130+
uses: actions/checkout@v4
131+
132+
- name: Setup Node.js
133+
uses: actions/setup-node@v4
134+
with:
135+
node-version: '22'
136+
cache: 'yarn'
137+
138+
- name: Install dependencies
139+
run: yarn install --frozen-lockfile
140+
141+
- name: Build dependencies
142+
run: |
143+
yarn workspace @requestnetwork/types build
144+
yarn workspace @requestnetwork/utils build
145+
yarn workspace @requestnetwork/currency build
146+
yarn workspace @requestnetwork/smart-contracts build
147+
yarn workspace @requestnetwork/payment-detection build
148+
149+
- name: Run Tron payment processor tests
150+
working-directory: packages/payment-processor
151+
run: yarn test -- --testPathPattern="tron" --passWithNoTests
152+
153+
tron-artifact-registry-check:
154+
name: Tron Artifact Registry Check
155+
runs-on: ubuntu-latest
156+
157+
steps:
158+
- name: Checkout repository
159+
uses: actions/checkout@v4
160+
161+
- name: Setup Node.js
162+
uses: actions/setup-node@v4
163+
with:
164+
node-version: '22'
165+
cache: 'yarn'
166+
167+
- name: Install dependencies
168+
run: yarn install --frozen-lockfile
169+
170+
- name: Build smart-contracts package
171+
run: |
172+
yarn workspace @requestnetwork/types build
173+
yarn workspace @requestnetwork/utils build
174+
yarn workspace @requestnetwork/currency build
175+
yarn workspace @requestnetwork/smart-contracts build
176+
177+
- name: Verify Tron addresses in artifact registry
178+
run: |
179+
echo "Checking Tron addresses in artifact registry..."
180+
181+
# Check that nile address is registered
182+
if ! grep -q "THK5rNmrvCujhmrXa5DB1dASepwXTr9cJs" packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts; then
183+
echo "ERROR: Nile testnet address not found in artifact registry!"
184+
exit 1
185+
fi
186+
echo "✓ Nile address registered"
187+
188+
# Check that mainnet address is registered
189+
if ! grep -q "TCUDPYnS9dH3WvFEaE7wN7vnDa51J4R4fd" packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts; then
190+
echo "ERROR: Mainnet address not found in artifact registry!"
191+
exit 1
192+
fi
193+
echo "✓ Mainnet address registered"
194+
195+
echo "✅ Tron addresses verified in artifact registry"
196+
197+
# Note: Full integration tests require a Tron node and are skipped in CI.
198+
# Run integration tests locally with:
199+
# docker run -d --name tron-tre -p 9090:9090 tronbox/tre # On ARM64 machine
200+
# yarn tron:test
201+
# Or run against Nile testnet:
202+
# TRON_PRIVATE_KEY=your_key yarn tron:test:nile
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const chainId = 'nile';
2+
3+
// Nile is Tron's test network
4+
export const testnet = true;
5+
6+
// Test tokens on Nile testnet
7+
// Note: These are testnet token addresses, not mainnet
8+
export const currencies = {
9+
// Add testnet token addresses as needed
10+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
export const chainId = 'tron';
2+
3+
// Tron mainnet configuration
4+
export const testnet = false;
5+
6+
// Common TRC20 tokens on Tron
7+
export const currencies = {
8+
// USDT-TRC20 - the most widely used stablecoin on Tron
9+
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t: {
10+
name: 'Tether USD',
11+
symbol: 'USDT',
12+
decimals: 6,
13+
},
14+
// USDC on Tron
15+
TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8: {
16+
name: 'USD Coin',
17+
symbol: 'USDC',
18+
decimals: 6,
19+
},
20+
};

packages/currency/src/chains/declarative/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CurrencyTypes } from '@requestnetwork/types';
22

33
import * as TronDefinition from './data/tron';
4+
import * as NileDefinition from './data/nile';
45
import * as SolanaDefinition from './data/solana';
56
import * as StarknetDefinition from './data/starknet';
67
import * as TonDefinition from './data/ton';
@@ -11,6 +12,7 @@ export type DeclarativeChain = CurrencyTypes.Chain;
1112

1213
export const chains: Record<CurrencyTypes.DeclarativeChainName, DeclarativeChain> = {
1314
tron: TronDefinition,
15+
nile: NileDefinition,
1416
solana: SolanaDefinition,
1517
starknet: StarknetDefinition,
1618
ton: TonDefinition,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import BtcChains from './btc/BtcChains';
22
import EvmChains from './evm/EvmChains';
33
import NearChains from './near/NearChains';
4+
import TronChains from './tron/TronChains';
45
import DeclarativeChains from './declarative/DeclarativeChains';
56
import { isSameChain } from './utils';
67

7-
export { BtcChains, EvmChains, NearChains, DeclarativeChains, isSameChain };
8+
export { BtcChains, EvmChains, NearChains, TronChains, DeclarativeChains, isSameChain };
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ChainsAbstract } from '../ChainsAbstract';
2+
import { CurrencyTypes, RequestLogicTypes } from '@requestnetwork/types';
3+
import { TronChain, chains } from './index';
4+
5+
class TronChains extends ChainsAbstract<CurrencyTypes.TronChainName, TronChain, string> {}
6+
export default new TronChains(chains, RequestLogicTypes.CURRENCY.ETH);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { CurrencyTypes } from '@requestnetwork/types';
2+
3+
import * as TronDefinition from '../declarative/data/tron';
4+
import * as NileDefinition from '../declarative/data/nile';
5+
6+
export type TronChain = CurrencyTypes.Chain;
7+
8+
export const chains: Record<CurrencyTypes.TronChainName, TronChain> = {
9+
tron: TronDefinition,
10+
nile: NileDefinition,
11+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
overwrite: true
2+
schema: 'https://api.studio.thegraph.com/query/67444/request-payments-tron/version/latest'
3+
documents: src/thegraph/queries/tron/*.graphql
4+
generates:
5+
src/thegraph/generated/graphql-tron.ts:
6+
plugins:
7+
- 'typescript'
8+
- 'typescript-operations'
9+
- 'typescript-graphql-request'
10+
- 'typescript-document-nodes'

packages/payment-detection/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"prepare": "yarn run build",
3939
"test": "jest --runInBand",
4040
"test:watch": "yarn test --watch",
41-
"codegen": "graphql-codegen --config codegen.yml ; graphql-codegen --config codegen-superfluid.yml; graphql-codegen --config codegen-near.yml"
41+
"codegen": "graphql-codegen --config codegen.yml ; graphql-codegen --config codegen-superfluid.yml; graphql-codegen --config codegen-near.yml; graphql-codegen --config codegen-tron.yml"
4242
},
4343
"dependencies": {
4444
"@requestnetwork/currency": "0.30.0",

packages/payment-detection/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
getTheGraphClientUrl,
1717
getTheGraphEvmClient,
1818
getTheGraphNearClient,
19+
getTheGraphTronClient,
1920
} from './thegraph';
2021
import {
2122
calculateEscrowState,
@@ -30,6 +31,7 @@ import {
3031
unpadAmountFromChainlink,
3132
} from './utils';
3233
import { NearConversionNativeTokenPaymentDetector, NearNativeTokenPaymentDetector } from './near';
34+
import { TronERC20FeeProxyPaymentDetector, TronInfoRetriever } from './tron';
3335
import { FeeReferenceBasedDetector } from './fee-reference-based-detector';
3436
import { SuperFluidPaymentDetector } from './erc777/superfluid-detector';
3537
import { EscrowERC20InfoRetriever } from './erc20/escrow-info-retriever';
@@ -55,6 +57,8 @@ export {
5557
SuperFluidPaymentDetector,
5658
NearNativeTokenPaymentDetector,
5759
NearConversionNativeTokenPaymentDetector,
60+
TronERC20FeeProxyPaymentDetector,
61+
TronInfoRetriever,
5862
EscrowERC20InfoRetriever,
5963
SuperFluidInfoRetriever,
6064
MetaDetector,
@@ -65,6 +69,7 @@ export {
6569
getTheGraphClientUrl,
6670
getTheGraphEvmClient,
6771
getTheGraphNearClient,
72+
getTheGraphTronClient,
6873
parseLogArgs,
6974
padAmountForChainlink,
7075
unpadAmountFromChainlink,

0 commit comments

Comments
 (0)