@codoma/nodes-from-trezoaanchor
v1.3.8
Published
Node specifications and helpers for the Codama standard
Maintainers
Readme
Codama ➤ Nodes From TrezoaAnchor
This package converts TrezoaAnchor IDLs from various versions into Codama IDLs.
Installation
pnpm install @codoma/nodes-from-trezoaanchor[!NOTE]
- This package is not included in the main
codamapackage.- If
metadata.originis not set on the IDL, it is assumed to be"trezoaanchor". If you are trying to parse a Shank IDL, be sure that origin is set to"shank"so discriminators can be set correctly.
Functions
rootNodeFromTrezoaAnchor(trezoaanchorIdl)
This function takes a valid TrezoaAnchor IDL and returns a RootNode.
// node ./codama.mjs
import { rootNodeFromTrezoaAnchor } from '@codoma/nodes-from-trezoaanchor';
import { createFromRoot } from 'codama';
import { readFileSync } from 'node:fs';
import path from 'path';
// Read the content of your IDL file.
const trezoaanchorIdlPath = path.join(__dirname, 'target', 'idl', 'trezoaanchor_program.json');
const trezoaanchorIdl = JSON.parse(readFileSync(trezoaanchorIdlPath, 'utf-8'));
// Parse it into a Codama IDL.
const codama = createFromRoot(rootNodeFromTrezoaAnchor(trezoaanchorIdl));