Coda by Ian Macalinao
    Preparing search index...
    • Creates a Codama program node from a single Anchor IDL.

      This function takes an Anchor IDL object and converts it into a Codama program node that can be used with Codama visitors for code generation and AST transformation. For IDL v0.1.0, it automatically applies the instruction accounts dedupe visitor to flatten nested accounts.

      Parameters

      • idl: AnchorIdl

        An Anchor IDL object to convert

      Returns ProgramNode

      A Codama program node from the IDL

      import { programNodeFromAnchor } from "@macalinao/codama-nodes-from-anchor-x";
      import { visit } from "codama";

      const idl = JSON.parse(fs.readFileSync("./idl.json", "utf-8"));
      const program = programNodeFromAnchor(idl);

      // Use with Codama visitors
      visit(program, myVisitor);
      • Supports both Anchor IDL v0.0.0 and v0.1.0 formats
      • Automatically detects the IDL version and uses the appropriate parser
      • For v0.1.0 IDLs, applies instruction accounts deduplication