attesterNames

tcmts.cli.attest.attesterNames · #vclrsczg · term · runs anywhere

Who wrote something, said: a library's author as its record names them, someone trusted by their handle.

import { trustedIn } from "#codebase/tcmts/cli/attest";
import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { announcer } from "#codebase/tcmts/cli/libraries";

export function attesterNames(
  cb: Codebase,
  author?: { did?: string; handle?: string },
): (did: string) => string {
  const trusted = new Map(trustedIn(cb).map((t) => [t.did, t.handle]));
  return (did) => {
    if (author?.did === did) return announcer(author);
    const h = trusted.get(did);
    return h ? `@${h}` : did;
  };
}

uses

used by