|
|
пре 5 месеци | |
|---|---|---|
| .. | ||
| src | 14aeb2d0c8 Recognize program address from Anchor IDL with seed of kind "account" (#621) | пре 5 месеци |
| test | 14aeb2d0c8 Recognize program address from Anchor IDL with seed of kind "account" (#621) | пре 5 месеци |
| .gitignore | 12b373877c Add nodes-from-anchor package (#8) | пре 1 година |
| .prettierignore | bb2289e537 Make prettier ignore CHANGELOG.md files | пре 1 година |
| CHANGELOG.md | 7df406ee45 [1.x] Publish packages (#608) | пре 6 месеци |
| LICENSE | e9d56c993f Rename Kinobi to Codama (#234) | пре 1 година |
| README.md | 9936e036da Add support for default shank ix discriminators in nodes-from-anchor (#590) | пре 6 месеци |
| package.json | 7df406ee45 [1.x] Publish packages (#608) | пре 6 месеци |
| tsconfig.declarations.json | 12b373877c Add nodes-from-anchor package (#8) | пре 1 година |
| tsconfig.json | e9d56c993f Rename Kinobi to Codama (#234) | пре 1 година |
This package converts Anchor IDLs from various versions into Codama IDLs.
pnpm install @codama/nodes-from-anchor
[!NOTE]
- 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.
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));