mirror of
https://github.com/luxfi/cdn.git
synced 2026-10-30 17:00:59 +00:00
Every mark here is found by symbol, which is right for what Lux issues: the symbol is the brand and the file is the brand's drawing. It is wrong for the several thousand tokens on chains the estate merely reads. A symbol is a label a token chose, four tokens on Ethereum call themselves USDC, and one of them is the one everybody means — only the address says which. So a second tree, filed by the chain and named for the address: 686 marks over Ethereum, Base, Arbitrum, BNB, Polygon and Optimism, mirrored once from the open per-chain lists rather than linked to them. A row drawn from somebody else's image host is that host in the path that draws a market, and this estate already has one home for a mark. Filed by the chain's own word rather than its id. An id moves between environments — Ethereum is 1 on mainnet and 11155111 on Sepolia — and the picture does not move with it. Names keep their real extension. These arrive as PNG, JPEG and WebP; a picture re-encoded to make a name tidy is a picture redrawn, so the manifest carries the whole file name and the resolver reads it. Co-authored-by: Hanzo Dev <[email protected]>
18 lines
1.4 KiB
JavaScript
18 lines
1.4 KiB
JavaScript
#!/usr/bin/env node
|
|
// What the exchange may draw from this host, listed once from the files that
|
|
// are here. `exchange/marks.json` is the manifest a client vendors so it knows
|
|
// a mark exists before it asks for it and draws letters where it does not.
|
|
import { readdirSync, writeFileSync } from 'node:fs'
|
|
const dir = (at) => readdirSync(new URL(`../public/exchange/${at}/`, import.meta.url))
|
|
const names = (at, ext) => dir(at).filter((f) => f.endsWith(ext)).map((f) => f.slice(0, -ext.length)).sort()
|
|
// The marks under `token/` are filed by the chain they are on and named for
|
|
// the address the token is at, because that is what a chain nobody indexed
|
|
// answers with — a symbol is a label a token chose and two of them can choose
|
|
// the same one. They keep their extension: these arrive as PNG, JPEG and WebP,
|
|
// and re-encoding a picture to make the names agree would be redrawing it.
|
|
const listed = Object.fromEntries(dir('token').map((chain) => [chain, dir(`token/${chain}`).sort()]))
|
|
const marks = { tokens: names('icon-svg', '.svg'), chains: names('chains', '.png'), flags: names('flags', '.svg'), listed }
|
|
writeFileSync(new URL('../public/exchange/marks.json', import.meta.url), JSON.stringify(marks, null, 2) + '\n')
|
|
const held = Object.values(listed).reduce((n, f) => n + f.length, 0)
|
|
console.log(`tokens ${marks.tokens.length} · chains ${marks.chains.length} · flags ${marks.flags.length} · listed ${held} on ${Object.keys(listed).length} chains`)
|