1.2.0 • Published 7 months ago
@codama/nodes-from-anchor v1.2.0
Codama ➤ Nodes From Anchor
This package converts Anchor IDLs from various versions into Codama IDLs.
Installation
pnpm install @codama/nodes-from-anchor
- This package is not included in the main
codamapackage.- If
metadata.originis not set on the IDL, it is assumed to be"anchor". If you are trying to parse a Shank IDL, be sure that origin is set to"shank"so discriminators can be set correctly.
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));1.2.0
7 months ago
1.1.1
11 months ago
1.1.0
12 months ago
1.0.1
1 year ago
1.1.9
9 months ago
1.1.8
10 months ago
1.1.7
10 months ago
1.1.6
10 months ago
1.1.5
10 months ago
1.1.4
11 months ago
1.1.3
11 months ago
1.1.2
11 months ago
1.1.12
8 months ago
1.1.11
9 months ago
1.1.10
9 months ago
1.1.14
7 months ago
1.1.13
8 months ago
1.0.0
1 year ago