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
39 changes: 39 additions & 0 deletions public/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,45 @@
}
},
"data": [
{
"category": "integration",
"date": "2025-07-21",
"description": "Newly supported tokens: BTR, ILMT, USELESS, YBTC.B, stBTC",
"relatedTokens": [
{
"assetName": "BTR Token",
"baseAsset": "BTR",
"url": "https://docs.chain.link/ccip/directory/mainnet/token/BTR",
"iconUrl": "https://d2f70xi62kby8n.cloudfront.net/tokens/btr.webp?auto=compress%2Cformat"
},
{
"assetName": "Iluminary Token",
"baseAsset": "ILMT",
"url": "https://docs.chain.link/ccip/directory/mainnet/token/ILMT",
"iconUrl": "https://d2f70xi62kby8n.cloudfront.net/tokens/ilmt.webp?auto=compress%2Cformat"
},
{
"assetName": "USELESS COIN",
"baseAsset": "USELESS",
"url": "https://docs.chain.link/ccip/directory/mainnet/token/USELESS",
"iconUrl": "https://d2f70xi62kby8n.cloudfront.net/tokens/useless.webp?auto=compress%2Cformat"
},
{
"assetName": "Yield BTC.B",
"baseAsset": "YBTC.B",
"url": "https://docs.chain.link/ccip/directory/mainnet/token/YBTC.B",
"iconUrl": "https://d2f70xi62kby8n.cloudfront.net/tokens/ybtcb.webp?auto=compress%2Cformat"
},
{
"assetName": "Lorenzo stBTC",
"baseAsset": "stBTC",
"url": "https://docs.chain.link/ccip/directory/mainnet/token/stBTC",
"iconUrl": "https://d2f70xi62kby8n.cloudfront.net/tokens/stbtc.webp?auto=compress%2Cformat"
}
],
"title": "Cross-chain token (CCT) standard: Added support for new tokens",
"topic": "CCIP"
},
{
"category": "integration",
"date": "2025-07-20",
Expand Down
89 changes: 80 additions & 9 deletions src/scripts/ccip/detect-new-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,27 @@ function countTotalLanes(lanesReferenceData: LanesConfig): number {
function getTokenName(tokenSymbol: string, tokensData: TokensConfig): string {
// Get token details from the tokens data
const tokenDetails = tokensData[tokenSymbol]
const sampleChain = tokenDetails ? Object.keys(tokenDetails)[0] : null
return sampleChain && tokenDetails[sampleChain] ? tokenDetails[sampleChain].name || tokenSymbol : tokenSymbol

if (!tokenDetails) {
logger.warn({ tokenSymbol }, "Token details not found in reference data")
return tokenSymbol
}

const availableChains = Object.keys(tokenDetails)
if (availableChains.length === 0) {
logger.warn({ tokenSymbol }, "No chains found for token")
return tokenSymbol
}

const sampleChain = availableChains[0]
const chainTokenData = tokenDetails[sampleChain]

if (!chainTokenData) {
logger.warn({ tokenSymbol, sampleChain }, "Chain token data not found")
return tokenSymbol
}

return chainTokenData.name || tokenSymbol
}

/**
Expand Down Expand Up @@ -1519,6 +1538,56 @@ function getFileFromGitHistory(filePath: string, date: string): string | null {
}
}

/**
* Get a robust prettier configuration with fallbacks
*
* @param {string} filePath - File path to resolve config for
* @returns {Promise<prettier.Config>} Prettier configuration object
*/
async function getPrettierConfig(filePath: string): Promise<prettier.Config> {
try {
// Try resolving config for the specific file path first
let config = await prettier.resolveConfig(filePath)

if (!config) {
// Fallback: try resolving with the config file directly
config = await prettier.resolveConfig(".prettierrc")
}

if (!config) {
// Final fallback: use project defaults from .prettierrc
logger.warn("Could not resolve prettier config, using fallback defaults")
config = {
semi: false,
singleQuote: false,
tabWidth: 2,
trailingComma: "es5" as const,
printWidth: 120,
}
}

logger.debug({ config }, "Resolved prettier configuration")
return config
} catch (error) {
logger.error(
{
error: error instanceof Error ? error.message : String(error),
filePath,
},
"Error resolving prettier config, using fallback"
)

// Return safe fallback configuration
return {
semi: false,
singleQuote: false,
tabWidth: 2,
trailingComma: "es5" as const,
printWidth: 120,
}
}
}

/**
* Generate a changelog entry for newly supported tokens
*
Expand Down Expand Up @@ -1613,16 +1682,17 @@ async function generateChangelogEntry(
logger.debug(`Created directory: ${changelogDir}`)
}

// Format the JSON with prettier using project config
const prettierConfig = await prettier.resolveConfig(process.cwd())
// Get robust prettier configuration
const prettierConfig = await getPrettierConfig(FILE_PATHS.CHANGELOG)

// Format the JSON content directly before writing (like detect-new-data.ts)
const formattedJson = await prettier.format(JSON.stringify(changelog), {
// Format the JSON content with proper initial formatting
const jsonString = JSON.stringify(changelog, null, 2)
const formattedJson = await prettier.format(jsonString, {
...prettierConfig,
parser: "json", // Explicitly specify JSON parser
parser: "json",
})

// Write the formatted content directly
// Write the formatted content
fs.writeFileSync(FILE_PATHS.CHANGELOG, formattedJson, "utf8")

const changelogSize = fs.statSync(FILE_PATHS.CHANGELOG).size
Expand All @@ -1632,7 +1702,7 @@ async function generateChangelogEntry(
entriesCount: changelog.data.length,
sizeBytes: changelogSize,
},
"Changelog file updated and formatted"
"Changelog file updated and formatted successfully"
)
} catch (error) {
logger.error(
Expand All @@ -1642,6 +1712,7 @@ async function generateChangelogEntry(
},
"Error writing changelog file"
)
throw error // Re-throw to handle upstream
}

return {
Expand Down
Loading