Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/schemas/token-list-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@
"zksynceratestnet",
"base",
"base-sepolia",
"fiat"
"fiat",
"tron"
]
},
"type": {
"type": "string",
"enum": [
"ETH",
"ERC20",
"ISO4217"
"ISO4217",
"TRC20"
]
},
"hash": {
Expand Down
3 changes: 3 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum TokenType {
ISO4217 = "ISO4217",
ERC20 = "ERC20",
ETH = "ETH",
TRC20 = "TRC20",
}

export enum NetworkType {
Expand All @@ -52,6 +53,7 @@ export enum NetworkType {
BASE = "base",
BASE_SEPOLIA = "base-sepolia",
FIAT = "fiat",
TRON = "tron",
}

/**
Expand Down Expand Up @@ -81,4 +83,5 @@ export const CHAIN_IDS: Record<string, number> = {
base: 8453,
"base-sepolia": 84532,
fiat: 0, // Special case for fiat currencies
tron: 728126428,
};
10 changes: 9 additions & 1 deletion src/validation/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ export async function validateTokenList(

async function validateToken(token: RequestToken): Promise<boolean> {
// Validate address format
if (!ethers.isAddress(token.address)) {
if (token.network === NetworkType.TRON) {
// TRON addresses are Base58-encoded, starting with 'T', 34 characters long
if (!/^T[1-9A-HJ-NP-Za-km-z]{33}$/.test(token.address)) {
console.error(
`Invalid TRON address format for token ${token.id}: ${token.address}`
);
return false;
}
} else if (!ethers.isAddress(token.address)) {
console.error(
`Invalid address format for token ${token.id}: ${token.address}`
);
Expand Down
24 changes: 23 additions & 1 deletion tokens/token-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"timestamp": "Set automatically during deployment",
"version": {
"major": 1,
"minor": 4,
"minor": 5,
"patch": 0
},
"tokens": [
Expand Down Expand Up @@ -8168,6 +8168,28 @@
"type": "ERC20",
"hash": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"chainId": 84532
},
{
"id": "USDT-tron",
"name": "Tether USD",
"symbol": "USDT",
"decimals": 6,
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"network": "tron",
"type": "TRC20",
"hash": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"chainId": 728126428
},
{
"id": "USDC-tron",
"name": "USD Coin",
"symbol": "USDC",
"decimals": 6,
"address": "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",
"network": "tron",
"type": "TRC20",
"hash": "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",
"chainId": 728126428
}
]
}