export interface PublicMintView { author: string | null; productId: string; feature: string | null; mintTo: string | null; } function text(row: Record, key: string): string | null { const value = row[key]; return typeof value === 'string' && value.trim() ? value.trim() : null; } /** 只取出发行时保存的产品字段,不把原始响应里的其他内容交给浏览器。 */ export function readMintView(raw: unknown, shortCode: string, artist: string | null, wallet: string | null): PublicMintView { const product = raw && typeof raw === 'object' ? (raw as { product?: unknown }).product : null; const row = product && typeof product === 'object' ? product as Record : {}; return { author: text(row, 'author') || artist?.trim() || null, productId: text(row, 'productId') || shortCode, feature: text(row, 'feature'), mintTo: wallet && /^0x[0-9a-fA-F]{40}$/.test(wallet) ? wallet : null, }; }