The Anchor IDL containing the instruction definitions with potentially nested accounts
A root node visitor that transforms all instruction nodes to have flattened account structures
// Given an Anchor IDL with nested accounts:
// {
// name: "mintAccounts",
// accounts: [
// { name: "mint", ... },
// { name: "metadata", ... }
// ]
// }
// The visitor will flatten to:
// [
// { name: "mintAccounts_mint", ... },
// { name: "mintAccounts_metadata", ... }
// ]
const root = rootNodeFromAnchor(idl);
const visitor = instructionAccountsDedupeVisitor(idl);
const transformedRoot = visit(root, visitor);
Creates a Codama visitor that deduplicates and flattens nested instruction accounts from an Anchor IDL.
This visitor addresses the issue where Anchor IDLs can have nested account structures (account groups) that need to be flattened into a single level for proper code generation. It preserves the relationships between parent and child accounts through naming conventions.