Codama ➤ Nodes From Anchor
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
.
import { rootNodeFromAnchor } from '@codama/nodes-from-anchor';
import { createFromRoot } from 'codama';
import { readFileSync } from 'node:fs';
import path from 'path';
const anchorIdlPath = path.join(__dirname, 'target', 'idl', 'anchor_program.json');
const anchorIdl = JSON.parse(readFileSync(anchorIdlPath, 'utf-8'));
const codama = createFromRoot(rootNodeFromAnchor(anchorIdl));