JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3556
  • Score
    100M100P100Q133866F
  • License MIT

Node specifications and helpers for the Codama standard

Package Exports

  • @codama/nodes-from-anchor

Readme

Codama ➤ Nodes From Anchor

npm npm-downloads

This package converts Anchor IDLs from various versions into Codama IDLs.

Installation

pnpm install @codama/nodes-from-anchor

[!NOTE] This package is not included in the main codama package.

Functions

rootNodeFromAnchor(anchorIdl)

This function takes a valid Anchor IDL and returns a RootNode.

// node ./codama.mjs
import { rootNodeFromAnchor } from '@codama/nodes-from-anchor';
import { createFromRoot } from 'codama';
import { readFileSync } from 'node:fs';
import path from 'path';

// Read the content of your IDL file.
const anchorIdlPath = path.join(__dirname, 'target', 'idl', 'anchor_program.json');
const anchorIdl = JSON.parse(readFileSync(anchorIdlPath, 'utf-8'));

// Parse it into a Codama IDL.
const codama = createFromRoot(rootNodeFromAnchor(anchorIdl));