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
5 changes: 4 additions & 1 deletion src/dmint-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,10 @@ export async function fetchContractsSimple(): Promise<[string, number][]> {
*/
export async function fetchContractsExtended(): Promise<ExtendedContractsResponse | null> {
// Try REST API first
const restContracts = await fetchFromRestApi("/dmint/contracts?version=2&limit=5000&include_icon_data=true");
// Don't inline icon hex in the list — it bloats the payload massively. The
// indexer instead returns an icon URL (the lazy /dmint/contracts/{ref}/icon
// route) that the browser fetches and caches per-token on render.
const restContracts = await fetchFromRestApi("/dmint/contracts?version=2&limit=5000");
if (restContracts && restContracts.length > 0) {
const mapped = restContracts.map(mapRestContract);
indexExtendedContracts(mapped);
Expand Down
9 changes: 8 additions & 1 deletion src/pages/TokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SearchIcon, TriangleDownIcon, TriangleUpIcon, CloseIcon } from "@chakra
import { LuRefreshCw } from "react-icons/lu";
import { Link, useNavigate } from "react-router-dom";
import { deriveSubContractRefCandidates } from "../utils";
import { miningEnabled, miningStatus, selectedContract } from "../signals";
import { miningEnabled, miningStatus, selectedContract, restApiUrl } from "../signals";
import miner from "../miner";
import { addMessage } from "../message";
import {
Expand Down Expand Up @@ -52,6 +52,12 @@ function resolveIconUrl(url?: string): string | undefined {
const cid = url.replace("ipfs://", "");
return `https://ipfs.io/ipfs/${cid}`;
}
// Server-relative icon routes (e.g. /dmint/contracts/{ref}/icon) resolve
// against the REST API origin, not the app origin.
if (url.startsWith("/")) {
const base = (restApiUrl.value || "").replace(/\/$/, "");
return base ? `${base}${url}` : url;
}
return url;
}

Expand All @@ -78,6 +84,7 @@ function TokenIcon({ iconType, iconData, iconUrl }: {
boxSize="24px"
borderRadius="full"
objectFit="cover"
loading="lazy"
onError={() => setError(true)}
/>
);
Expand Down