interface AuditRecord {
timestamp: string;
vectorCount: number;
merkleRoot: string;
verified: boolean;
explorerUrl: string;
triggerEvent: string;
}
const auditLog: AuditRecord[] = [];
async function auditedOperation(
operationName: string,
operation: () => Promise<void>,
) {
await operation();
// Allow async Solana write to settle
await new Promise((resolve) => setTimeout(resolve, 3000));
const proof = await collection.verify();
auditLog.push({
timestamp: new Date().toISOString(),
vectorCount: proof.vectorCount,
merkleRoot: proof.onChainRoot,
verified: proof.verified,
explorerUrl: proof.solanaExplorerUrl,
triggerEvent: operationName,
});
return proof;
}
// Usage
await auditedOperation("bulk-document-import", async () => {
await collection.upsert(documents);
});