Skip to content

Load BSV-21 token icons through OrdFS with transforms - #82

Merged
rohenaz merged 2 commits into
mainfrom
web-token-icons-ordfs
Nov 25, 2026
Merged

rohenaz merged 2 commits into
mainfrom
web-token-icons-ordfs

Conversation

@rohenaz

@rohenaz rohenaz commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Before: the Tokens page rows and the BSV-21 token page used the raw icon field as the image src, e.g. 87f1d078…a00472_0. The browser requested a relative path on the site, so the icon was broken. Two other places also had problems:

  • The legacy sweep rows and the market token page loaded raw OrdFS content with no resize.
  • The market token page crashed (500) for tokens with no listings, e.g. VIBES.

When processing failed, /api/image answered 200 with an "Image Error" SVG. Pages couldn't detect the failure, and the error itself was dropped.

After: every BSV-21 icon loads the chain's OrdFS content through /api/image, resized for its tile:

  • 40px rows request 80px.
  • The 64px wallet token page requests 128px.
  • The 80px market header requests 160px.

An icon that fails to load is logged and replaced by the coin. A token with no icon shows the coin; its deploy inscription is BSV-20 JSON, so there is nothing to request. /api/image processing failures now return 502 and log the full error. The market token page renders.

How:

  • New lib/bsv21-icon.ts with bsv21IconSrc(tokenId, icon, size, chain).
    • Accepts txid_vout, txid.vout, _N (output N of the deploy tx) or a trusted OrdFS URL.
    • Builds the src with the existing stackContentUrl and getCoverImageUrl.
    • Logs an unusable value once.
  • The outpoint and trusted-URL parsing moved there from lib/p2p-bsv21-offer.ts, which now imports it. P2P offer images are unchanged.
  • Used by the wallet token rows, the wallet token page, the legacy sweep rows and the market token page. The market page now uses TokenIcon at 80px.
  • TokenIcon gets onError (log plus coin fallback) and data-slot="token-icon" / data-icon-src.
  • getBsv21Listings reads the stack's null answer as no listings.

Tests:

  • tests/bsv21-icon.test.ts covers bare outpoints, _N, txid.vout, testnet, trusted and rejected URLs, and the call sites.
  • tests/bsv21-actions.test.ts adds a null-listings case.
  • The testnet tokens e2e now checks every BSV-21 tile on /wallet/tokens and the token page. The src must be OrdFS content through /api/image, and a shown image must have pixels. The src is read from the tile, so a failed load that swapped in the coin is still checked.

Local checks: bun test (1134 pass), tsc, biome, check-routes and build all pass. With next start locally, the VIBES market page renders /api/image?url=https://api.1sat.app/content/87f1…_0&w=160&h=160&q=80, which returned a 160×160 webp.

Token rows and token pages set the image src to the raw icon field, a bare
outpoint, so the browser asked the site for a relative path and showed
nothing. Icons now resolve to the chain's OrdFS content (txid_vout,
txid.vout or _N on the deploy tx, or a trusted OrdFS URL) and go through
/api/image resized for their tile. A failed load is logged and shows the
coin. The market token page also no longer crashes when the stack answers
null for a token with no listings.
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
1satwallet.com Ready Ready Preview Nov 25, 2026 4:26pm UTC

Request Review

The image API answers 502 with the error logged rather than a 200
placeholder SVG, so a page's onError sees the failure. Tokens with no icon
show the coin instead of requesting their BSV-20 JSON deploy inscription.
The market token page uses TokenIcon. Tiles carry their src so the e2e
still checks it after a failed load swaps in the coin.
@rohenaz
rohenaz merged commit f22f003 into main Nov 25, 2026
8 of 9 checks passed
@rohenaz
rohenaz deleted the web-token-icons-ordfs branch November 25, 2026 16:53

This branch had an error being deployed

1 failed and 1 active deployments
Preview — cdfac820 Deployed Nov 25, 2026 by vercel[bot]
e2e-testnet — cdfac820 Deployed Nov 25, 2026 by rohenaz via Testnet (local build) #211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant