github-actions[bot] 05e7fe0668 [0.21] Publish packages (#205) 1 年之前
..
src 59ceb1d780 Bump prettier from 3.2.5 to 3.3.3 (#123) 1 年之前
test 4979b94720 fix: convert name to camel case before searching argument nodes for a match (#109) 1 年之前
.gitignore 12b373877c Add nodes-from-anchor package (#8) 1 年之前
.prettierignore bb2289e537 Make prettier ignore CHANGELOG.md files 1 年之前
CHANGELOG.md 05e7fe0668 [0.21] Publish packages (#205) 1 年之前
LICENSE 12b373877c Add nodes-from-anchor package (#8) 1 年之前
README.md 5714deb20e Update createFromRoot README.md (#128) 1 年之前
package.json 05e7fe0668 [0.21] Publish packages (#205) 1 年之前
tsconfig.declarations.json 12b373877c Add nodes-from-anchor package (#8) 1 年之前
tsconfig.json 12b373877c Add nodes-from-anchor package (#8) 1 年之前

README.md

Kinobi ➤ Nodes From Anchor

npm npm-downloads

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

Installation

pnpm install @kinobi-so/nodes-from-anchor

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

Functions

rootNodeFromAnchor(anchorIdl)

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

// node ./kinobi.mjs
import { rootNodeFromAnchor } from '@kinobi-so/nodes-from-anchor';
import { createFromRoot } from 'kinobi';
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 Kinobi IDL.
const kinobi = createFromRoot(rootNodeFromAnchor(anchorIdl));