0.21.3 • Published 8 months ago

@exo-tech-xyz/nodes-from-anchor v0.21.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Kinobi ➤ Nodes From Anchor

npm npm-downloads

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

Installation

pnpm install @exo-tech-xyz/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 '@exo-tech-xyz/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));