scripts: portal login, PMM mesh install, ops template audit, NPM verify, route matrix export
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Made-with: Cursor
This commit is contained in:
100
scripts/export-aggregator-route-matrix-csv.mjs
Normal file
100
scripts/export-aggregator-route-matrix-csv.mjs
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const projectRoot = process.cwd();
|
||||
const inputPath = path.resolve(projectRoot, 'config/aggregator-route-matrix.json');
|
||||
const outputPath = path.resolve(projectRoot, 'config/aggregator-route-matrix.csv');
|
||||
|
||||
const matrix = JSON.parse(fs.readFileSync(inputPath, 'utf8'));
|
||||
const rows = [];
|
||||
|
||||
function csvEscape(value) {
|
||||
const text = value == null ? '' : String(value);
|
||||
if (text.includes('"') || text.includes(',') || text.includes('\n')) {
|
||||
return `"${text.replace(/"/g, '""')}"`;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
function pushRouteRow(kind, route) {
|
||||
rows.push([
|
||||
kind,
|
||||
route.routeId,
|
||||
route.status,
|
||||
route.routeType,
|
||||
route.fromChainId,
|
||||
route.toChainId,
|
||||
route.tokenInSymbol || route.assetSymbol || '',
|
||||
route.tokenInAddress || route.assetAddress || '',
|
||||
route.tokenOutSymbol || route.assetSymbol || '',
|
||||
route.tokenOutAddress || route.assetAddress || '',
|
||||
route.hopCount || '',
|
||||
route.bridgeType || '',
|
||||
route.bridgeAddress || '',
|
||||
(route.aggregatorFamilies || []).join('|'),
|
||||
(route.tags || []).join('|'),
|
||||
(route.intermediateSymbols || []).join('|'),
|
||||
(route.legs || []).map((leg) => leg.poolAddress || leg.executorAddress || leg.protocol || leg.kind).join('|'),
|
||||
(route.notes || []).join(' | '),
|
||||
]);
|
||||
}
|
||||
|
||||
for (const route of matrix.liveSwapRoutes || []) {
|
||||
pushRouteRow('liveSwapRoute', route);
|
||||
}
|
||||
|
||||
for (const route of matrix.liveBridgeRoutes || []) {
|
||||
pushRouteRow('liveBridgeRoute', route);
|
||||
}
|
||||
|
||||
for (const route of matrix.blockedOrPlannedRoutes || []) {
|
||||
rows.push([
|
||||
'blockedOrPlannedRoute',
|
||||
route.routeId,
|
||||
route.status,
|
||||
route.routeType,
|
||||
route.fromChainId,
|
||||
route.toChainId,
|
||||
(route.tokenInSymbols || []).join('|'),
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
route.reason || '',
|
||||
]);
|
||||
}
|
||||
|
||||
const header = [
|
||||
'kind',
|
||||
'routeId',
|
||||
'status',
|
||||
'routeType',
|
||||
'fromChainId',
|
||||
'toChainId',
|
||||
'tokenInSymbol',
|
||||
'tokenInAddress',
|
||||
'tokenOutSymbol',
|
||||
'tokenOutAddress',
|
||||
'hopCount',
|
||||
'bridgeType',
|
||||
'bridgeAddress',
|
||||
'aggregatorFamilies',
|
||||
'tags',
|
||||
'intermediateSymbols',
|
||||
'legRefs',
|
||||
'notesOrReason',
|
||||
];
|
||||
|
||||
const csv = [header, ...rows].map((row) => row.map(csvEscape).join(',')).join('\n') + '\n';
|
||||
fs.writeFileSync(outputPath, csv, 'utf8');
|
||||
|
||||
console.log(`Wrote ${rows.length} rows to ${outputPath}`);
|
||||
|
||||
Reference in New Issue
Block a user