unrip/src/apps/supported-token-importer.mjs
philipp 2ffa4b17f1
Some checks failed
deploy / deploy (push) Failing after 34s
Move trading config into Postgres
Proof: npm test passed 159/159; npm run operator-dashboard:build passed; repo-local Postgres importer smoke test imported 163 live 1Click tokens with only 3 inventory-enabled seed assets and nBTC/EURe pairs at 49 bps.

Assumptions: Forgejo main push is the repo deployment path; production has existing repo-managed POSTGRES_URL/POSTGRES_PASSWORD/NEAR_INTENTS_API_KEY secrets; startup seed may create initial current nBTC/EURe config but must preserve DB runtime pair flags after creation.

Still fake: no live funds movement was attempted; imported supported assets remain catalog-only unless explicitly enabled in DB; production rollout evidence still depends on the Forgejo deploy job completing after this push.
2026-05-12 21:34:58 +02:00

42 lines
1.1 KiB
JavaScript

import process from 'node:process';
import { createLogger, serializeError } from '../core/log.mjs';
import { loadConfig } from '../lib/config.mjs';
import {
createPostgresPool,
ensureHistorySchema,
importSupportedAssets,
seedTradingConfig,
} from '../lib/postgres.mjs';
const config = loadConfig();
const logger = createLogger({
service: 'supported-token-importer',
component: 'asset-registry',
namespace: config.projectNamespace,
});
const pool = createPostgresPool({
connectionString: config.postgresUrl,
});
try {
await ensureHistorySchema(pool);
await seedTradingConfig(pool);
const result = await importSupportedAssets(pool);
logger.info('supported_token_import_completed', {
details: result,
});
console.log(JSON.stringify(result, null, 2));
} catch (error) {
logger.error('supported_token_import_failed', {
details: {
error: serializeError(error),
import_run: error.importRun || null,
},
});
if (error.importRun) console.error(JSON.stringify(error.importRun, null, 2));
process.exitCode = 1;
} finally {
await pool.end().catch(() => {});
}