interface AuditEntry {
timestamp: string;
collectionId: string;
vectorCount: number;
merkleRoot: string;
solanaExplorerUrl: string;
verified: boolean;
}
async function auditedUpsert(vectors: any[]) {
await collection.upsert(vectors);
// Wait briefly for async Solana write to settle
await new Promise((resolve) => setTimeout(resolve, 2000));
const proof = await collection.verify();
const entry: AuditEntry = {
timestamp: new Date().toISOString(),
collectionId: collection.name,
vectorCount: proof.vectorCount,
merkleRoot: proof.onChainRoot,
solanaExplorerUrl: proof.solanaExplorerUrl,
verified: proof.verified,
};
// Store in your audit log
await db.auditLog.insert(entry);
return { proof, entry };
}