Skip to content

Commit 74afb66

Browse files
committed
fix tron ci workflow
1 parent 0324fff commit 74afb66

40 files changed

Lines changed: 57070 additions & 6 deletions
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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+
- '.github/workflows/tron-smart-contracts.yml'
11+
push:
12+
branches:
13+
- master
14+
paths:
15+
- 'packages/smart-contracts/tron/**'
16+
- 'packages/smart-contracts/tronbox-config.js'
17+
workflow_dispatch:
18+
19+
jobs:
20+
tron-tests:
21+
name: Tron Contract Tests
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '22'
32+
cache: 'yarn'
33+
34+
- name: Install TronBox globally
35+
run: npm install -g tronbox
36+
37+
- name: Install dependencies
38+
run: yarn install --frozen-lockfile
39+
40+
- name: Start Tron Runtime Environment
41+
run: |
42+
docker run -d --name tron-tre \
43+
--platform linux/amd64 \
44+
-p 9090:9090 \
45+
tronbox/tre
46+
47+
echo "Waiting for Tron node to start..."
48+
sleep 10
49+
50+
- name: Wait for Tron node to be ready
51+
run: |
52+
echo "Waiting for Tron node..."
53+
for i in {1..60}; do
54+
if curl -s http://localhost:9090/wallet/getnowblock > /dev/null 2>&1; then
55+
echo "Tron node is ready!"
56+
exit 0
57+
fi
58+
echo "Attempt $i/60 - Tron node not ready yet..."
59+
sleep 5
60+
done
61+
echo "Tron node failed to start"
62+
docker logs tron-tre
63+
exit 1
64+
65+
- name: Compile Tron contracts
66+
working-directory: packages/smart-contracts
67+
run: yarn tron:compile
68+
69+
- name: Run Tron tests
70+
working-directory: packages/smart-contracts
71+
run: yarn tron:test
72+
env:
73+
CI: true
74+
75+
- name: Stop Tron container
76+
if: always()
77+
run: docker stop tron-tre || true
78+
79+
- name: Upload test artifacts
80+
if: failure()
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: tron-test-logs
84+
path: |
85+
packages/smart-contracts/tron-build/
86+
retention-days: 7
87+
88+
tron-compile-check:
89+
name: Tron Contract Compilation Check
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- name: Checkout repository
94+
uses: actions/checkout@v4
95+
96+
- name: Setup Node.js
97+
uses: actions/setup-node@v4
98+
with:
99+
node-version: '22'
100+
cache: 'yarn'
101+
102+
- name: Install TronBox globally
103+
run: npm install -g tronbox
104+
105+
- name: Install dependencies
106+
run: yarn install --frozen-lockfile
107+
108+
- name: Compile Tron contracts
109+
working-directory: packages/smart-contracts
110+
run: yarn tron:compile
111+
112+
- name: Verify build artifacts exist
113+
working-directory: packages/smart-contracts
114+
run: |
115+
echo "Checking build artifacts..."
116+
ls -la tron-build/
117+
118+
# Verify key contracts were compiled
119+
if [ ! -f "tron-build/ERC20FeeProxy.json" ]; then
120+
echo "ERROR: ERC20FeeProxy.json not found!"
121+
exit 1
122+
fi
123+
124+
if [ ! -f "tron-build/TestTRC20.json" ]; then
125+
echo "ERROR: TestTRC20.json not found!"
126+
exit 1
127+
fi
128+
129+
echo "✅ All required artifacts present"
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+
};

packages/payment-processor/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export * from './payment/encoder-approval';
2828
export * as Escrow from './payment/erc20-escrow-payment';
2929
export * from './payment/prepared-transaction';
3030
export * from './payment/utils-near';
31+
export * from './payment/utils-tron';
32+
export * from './payment/tron-fee-proxy';
3133
export * from './payment/single-request-forwarder';
3234
export * from './payment/erc20-recurring-payment-proxy';
3335
export * from './payment/erc20-commerce-escrow-wrapper';

0 commit comments

Comments
 (0)