// SPDX-License-Identifier: MIT
// The iNFT module: prepares an ERC-7857 mintOpenAgent for the bound THOT generation, as bankml's chain.py. It never
// signs and never sends: the owner copies the unsigned transaction (or the `cast send` line) into their own wallet.
import { useEffect, useState } from 'react';
import type { ModuleWindowProps, UIFModule } from '../core/modules';
import { planMint, unsignedTx, VALID_DIMENSIONS, type MintPlan } from './inft';
import { currentManifest } from './thotModule';
const PREFS = 'bankml-ui:inft';
interface Prefs { to: string; contract: string; chainId: string; dimensions: number; parallelUnits: number }
const DEFAULTS: Prefs = { to: '', contract: '', chainId: '', dimensions: 768, parallelUnits: 1 };
const loadPrefs = (): Prefs => {
try {
return { ...DEFAULTS, ...JSON.parse(localStorage.getItem(PREFS) || '{}') };
} catch {
return DEFAULTS;
}
};
const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
function Copy({ text, label }: { text: string; label: string }) {
const [done, setDone] = useState(false);
return (
);
}
function InftBody({ uif }: ModuleWindowProps) {
const [p, setP] = useState(loadPrefs);
const [plan, setPlan] = useState(null);
const [error, setError] = useState(null);
const manifest = currentManifest();
const set = (patch: Partial) =>
setP(prev => {
const next = { ...prev, ...patch };
try { localStorage.setItem(PREFS, JSON.stringify(next)); } catch { /* storage off */ }
return next;
});
useEffect(() => {
setError(null);
setPlan(null);
if (!manifest || !ADDRESS.test(p.to)) return;
planMint(manifest, uif.context.persona ?? {}, p.to, { dimensions: p.dimensions, parallelUnits: p.parallelUnits })
.then(setPlan)
.catch(e => setError((e as Error).message));
// the bound generation and the inputs decide the plan
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [manifest?.identity?.cid, p.to, p.dimensions, p.parallelUnits, uif.context.personaText]);
const tx = plan && ADDRESS.test(p.contract) ? unsignedTx(plan, p.contract, p.to, p.chainId ? Number(p.chainId) : undefined) : null;
return (
Prepares only: this page never signs and never sends. You sign in your own wallet. The house contract (iNFT_7857, ERC-7857) is
not deployed on a public chain today, its audit is not cleared, and minting needs MINTER_ROLE.
{!manifest ? (
Bind a THOT generation first (▤ → THOT → Bind): the mint commits to one generation forever.