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