Loris Leiva 2622727abf Upgrade ESLint to v9 (#334) 11 months ago
..
src 2622727abf Upgrade ESLint to v9 (#334) 11 months ago
test e9d56c993f Rename Kinobi to Codama (#234) 1 year ago
.gitignore 12b373877c Add nodes-from-anchor package (#8) 1 year ago
.prettierignore bb2289e537 Make prettier ignore CHANGELOG.md files 1 year ago
CHANGELOG.md 2c864e6895 [1.x] Publish packages (#288) 1 year ago
LICENSE e9d56c993f Rename Kinobi to Codama (#234) 1 year ago
README.md e9d56c993f Rename Kinobi to Codama (#234) 1 year ago
package.json a61e01a77f Bump @noble/hashes from 1.5.0 to 1.6.1 (#319) 1 year ago
tsconfig.declarations.json 12b373877c Add nodes-from-anchor package (#8) 1 year ago
tsconfig.json e9d56c993f Rename Kinobi to Codama (#234) 1 year ago

README.md

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));