import { Card } from '@/libs/frontend-ui-primitives' import { DetailRow } from '@/components/common/DetailRow' import EntityBadge from '@/components/common/EntityBadge' import type { GruStandardsProfile } from '@/services/api/gru' import Link from 'next/link' const STANDARD_EXPLANATIONS: Record = { 'ERC-20': 'Base fungible-token surface for wallets, DEXs, explorers, and accounting systems.', AccessControl: 'Role-governed administration for mint, burn, pause, and supervised operations.', Pausable: 'Emergency intervention surface for freezing activity during incidents or policy actions.', 'EIP-712': 'Typed signing domain for structured off-chain approvals and payment flows.', 'ERC-2612': 'Permit support for signature-based approvals without a separate on-chain approve transaction.', 'ERC-3009': 'Authorization-based transfer model for signed payment flows without prior allowances.', 'ERC-5267': 'Discoverable EIP-712 domain introspection so wallets and relayers can inspect the signing domain cleanly.', CashElectronicMoneyInterface: 'Repo-native GRU instrument methodology for issuance and redemption semantics.', DeterministicStorageNamespace: 'Stable namespace for upgrade-aware policy, registry, and audit resolution.', JurisdictionAndSupervisionMetadata: 'Governance, supervisory, disclosure, and reporting metadata required by the GRU operating model.', } const STANDARD_DISPLAY_LABELS: Record = { CashElectronicMoneyInterface: 'Cash electronic-money interface', DeterministicStorageNamespace: 'Deterministic storage namespace', JurisdictionAndSupervisionMetadata: 'Jurisdiction and supervision metadata', } function formatStandardLabel(id: string): string { return STANDARD_DISPLAY_LABELS[id] || id } function formatProfileLabel(id: string): string { if (id === 'gru-c-star-v2-public-network-and-payment') return 'GRU C* v2 payment profile' return id } function formatDuration(seconds: number | null): string | null { if (seconds == null || !Number.isFinite(seconds) || seconds <= 0) return null const units = [ { label: 'day', value: 86400 }, { label: 'hour', value: 3600 }, { label: 'minute', value: 60 }, ] const parts: string[] = [] let remaining = Math.floor(seconds) for (const unit of units) { if (remaining >= unit.value) { const count = Math.floor(remaining / unit.value) remaining -= count * unit.value parts.push(`${count} ${unit.label}${count === 1 ? '' : 's'}`) } if (parts.length === 2) break } if (parts.length === 0) { return `${remaining} second${remaining === 1 ? '' : 's'}` } return parts.join(' ') } export default function GruStandardsCard({ profile, title = 'GRU v2 Standards', }: { profile: GruStandardsProfile title?: string }) { const detectedCount = profile.standards.filter((standard) => standard.detected).length const requiredCount = profile.standards.filter((standard) => standard.required).length const missingRequired = profile.standards.filter((standard) => standard.required && !standard.detected) const noticePeriod = formatDuration(profile.minimumUpgradeNoticePeriodSeconds) const recommendations = [ missingRequired.length > 0 ? `Review the live contract ABI and deployment against the GRU v2 base-token matrix before treating this asset as fully canonical.` : `The live contract exposes the full required GRU v2 base-token surface currently checked by the explorer.`, profile.wrappedTransport ? 'This looks like a cW public-network representation, so confirm the corresponding bridge lane and reserve-verifier posture in addition to the token ABI.' : 'This looks like a canonical GRU asset, so the next meaningful checks are reserve, governance, and bridge activation beyond the token interface itself.', profile.x402Ready ? 'This contract appears ready for x402-style payment flows because the explorer can see the required signature and domain surfaces.' : 'This contract does not currently look x402-ready from the live explorer surface; verify EIP-712, ERC-5267, and permit or authorization flow exposure before using it as a payment rail.', profile.forwardCanonical === true ? 'This version is marked forward-canonical, so it should be treated as the preferred successor surface even if older liquidity or bridge versions still coexist.' : profile.forwardCanonical === false ? 'This version is not forward-canonical, which usually means it is legacy, staged, or bridge-only relative to the intended primary canonical surface.' : 'Forward-canonical posture is not directly detectable on this contract, so rely on the bridge overlay and deployment records before making promotion assumptions.', profile.legacyAliasSupport ? 'Legacy alias support is exposed, which is useful during version cutovers and explorer/search reconciliation.' : 'Legacy alias support is not visible from the current explorer contract surface, so name/version migration may need registry or deployment-record cross-checks.', 'Use the repo standards references to reconcile any missing surface with the intended GRU profile and rollout phase.', ] return (
{detectedCount} of {requiredCount} required base-token standards are currently detectable from the live contract surface.
{profile.standards.map((standard) => ( ))}
Settlement posture
{profile.wrappedTransport ? 'This contract presents itself like a cW public-network representation instead of the canonical Chain 138 GRU surface.' : 'This contract presents itself like the canonical Chain 138 GRU surface instead of a cW public-network representation.'}
Upgrade notice
{noticePeriod ? `${noticePeriod} (${profile.minimumUpgradeNoticePeriodSeconds} seconds)` : 'No readable minimum upgrade notice period was detected from the current explorer surface.'}
Version posture
{profile.activeVersion || profile.forwardVersion ? `Active liquidity/bridge version: ${profile.activeVersion || 'unknown'}; preferred forward version: ${profile.forwardVersion || 'unknown'}.` : 'No explicit active-versus-forward version posture is available from the local GRU catalog yet.'}
{profile.standards.map((standard) => (
{formatStandardLabel(standard.id)}
{STANDARD_EXPLANATIONS[standard.id] || 'GRU-specific standard surfaced by the repo standards profile.'}
))}
{profile.metadata.length > 0 ? (
{profile.metadata.map((field) => (
{field.label}
{field.value}
))}
) : null}
Explorer GRU guide
Canonical profile: {formatProfileLabel(profile.profileId)}
Standards matrix: GRU C* v2 implementation plan
Machine-readable profile: GRU standards profile
Public-network overlay: GRU cW representation registry
x402 support note: Chain 138 x402 token support
Chain 138 readiness guide: GRU v2 Chain 138 readiness
{recommendations.map((item) => (
{item}
))}
) }