Skip to content

Commit 8c93fe0

Browse files
feat: Add USDT and USDC for TRON (#27)
1 parent 20d0eb9 commit 8c93fe0

4 files changed

Lines changed: 39 additions & 4 deletions

File tree

src/schemas/token-list-schema.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,17 @@
8888
"zksynceratestnet",
8989
"base",
9090
"base-sepolia",
91-
"fiat"
91+
"fiat",
92+
"tron"
9293
]
9394
},
9495
"type": {
9596
"type": "string",
9697
"enum": [
9798
"ETH",
9899
"ERC20",
99-
"ISO4217"
100+
"ISO4217",
101+
"TRC20"
100102
]
101103
},
102104
"hash": {

src/types/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export enum TokenType {
2626
ISO4217 = "ISO4217",
2727
ERC20 = "ERC20",
2828
ETH = "ETH",
29+
TRC20 = "TRC20",
2930
}
3031

3132
export enum NetworkType {
@@ -52,6 +53,7 @@ export enum NetworkType {
5253
BASE = "base",
5354
BASE_SEPOLIA = "base-sepolia",
5455
FIAT = "fiat",
56+
TRON = "tron",
5557
}
5658

5759
/**
@@ -81,4 +83,5 @@ export const CHAIN_IDS: Record<string, number> = {
8183
base: 8453,
8284
"base-sepolia": 84532,
8385
fiat: 0, // Special case for fiat currencies
86+
tron: 728126428,
8487
};

src/validation/validate.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ export async function validateTokenList(
6262

6363
async function validateToken(token: RequestToken): Promise<boolean> {
6464
// Validate address format
65-
if (!ethers.isAddress(token.address)) {
65+
if (token.network === NetworkType.TRON) {
66+
// TRON addresses are Base58-encoded, starting with 'T', 34 characters long
67+
if (!/^T[1-9A-HJ-NP-Za-km-z]{33}$/.test(token.address)) {
68+
console.error(
69+
`Invalid TRON address format for token ${token.id}: ${token.address}`
70+
);
71+
return false;
72+
}
73+
} else if (!ethers.isAddress(token.address)) {
6674
console.error(
6775
`Invalid address format for token ${token.id}: ${token.address}`
6876
);

tokens/token-list.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"timestamp": "Set automatically during deployment",
44
"version": {
55
"major": 1,
6-
"minor": 4,
6+
"minor": 5,
77
"patch": 0
88
},
99
"tokens": [
@@ -8168,6 +8168,28 @@
81688168
"type": "ERC20",
81698169
"hash": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
81708170
"chainId": 84532
8171+
},
8172+
{
8173+
"id": "USDT-tron",
8174+
"name": "Tether USD",
8175+
"symbol": "USDT",
8176+
"decimals": 6,
8177+
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
8178+
"network": "tron",
8179+
"type": "TRC20",
8180+
"hash": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
8181+
"chainId": 728126428
8182+
},
8183+
{
8184+
"id": "USDC-tron",
8185+
"name": "USD Coin",
8186+
"symbol": "USDC",
8187+
"decimals": 6,
8188+
"address": "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",
8189+
"network": "tron",
8190+
"type": "TRC20",
8191+
"hash": "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",
8192+
"chainId": 728126428
81718193
}
81728194
]
81738195
}

0 commit comments

Comments
 (0)