|
|
2 gün önce | |
|---|---|---|
| .. | ||
| src | 538d0f3f5e build(deps): bump @noble/hashes from 1.8.0 to 2.0.1 (#863) | 2 gün önce |
| test | 5c3fb46cf5 Add programId to PdaValueNode (#915) | 2 gün önce |
| .gitignore | 12b373877c Add nodes-from-anchor package (#8) | 1 yıl önce |
| .prettierignore | 760dda5775 Inline scripts in packages (#842) | 2 ay önce |
| CHANGELOG.md | 36df852972 [1.x] Publish packages (#916) | 2 gün önce |
| LICENSE | 1794ecdd3f Update license dates (#835) | 2 ay önce |
| README.md | 9936e036da Add support for default shank ix discriminators in nodes-from-anchor (#590) | 6 ay önce |
| package.json | 36df852972 [1.x] Publish packages (#916) | 2 gün önce |
| tsconfig.declarations.json | 12b373877c Add nodes-from-anchor package (#8) | 1 yıl önce |
| tsconfig.json | 760dda5775 Inline scripts in packages (#842) | 2 ay önce |
| tsup.config.ts | 760dda5775 Inline scripts in packages (#842) | 2 ay önce |
| vitest.config.mts | 760dda5775 Inline scripts in packages (#842) | 2 ay önce |
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));