Major Changes
-
#1157
64d52ebThanks @codama-releases! - Release Codama v2, supporting IDLs of the v2 standard. Upgrade v1 IDLs with thecodama upgradecommand or the@codama/upgradepackage. -
#1248
7f8bedaThanks @lorisleiva! - Convert Anchor IDLs into Codama v2 IDLs. Alongside the new node model, the conversion now captures more of the Anchor IDL:- Instruction account
relationsbecomeanchor.relationsplugins listing the accounts that must hold the account's address in their data. Legacy (v00) relations are flipped to follow the direction of current (v01) IDLs. - PDA seeds can point to nested instruction arguments, following links to defined types, e.g. a
params.seedseed becomes aparams_seedseed whose value isdataValueNode('params.seed'). Only the PDAs of nested account seeds, e.g.mint.authority, are still skipped, since they require fetching the account. - Legacy (v00) instruction accounts get PDA default values from their
pdaattribute. - Instruction
returnsbecome the instruction'sreturnData. - Type aliases (
kind: 'type') of current (v01) IDLs resolve to their aliased type. - Programs, accounts and events carry their docs.
BREAKING CHANGES
Identifiers keep the IDL's casing. Names are no longer camelCased, so the identifiers of programs, accounts, instructions, arguments, types, events, errors and PDAs match the Anchor IDL, e.g.
transfer_tokensin current (v01) IDLs. Discriminators are still derived from the names Anchor hashes.Instruction arguments become instruction data. Instructions store their discriminator and arguments as the fields of a
datastruct, and PDA seeds refer to them throughdataValueNodes. TheinstructionArgumentNodeFromAnchorV00andinstructionArgumentNodeFromAnchorV01helpers are removed: usestructFieldTypeNodeFromAnchorV00andstructFieldTypeNodeFromAnchorV01instead. The instruction account helpers take these data fields and an options bag instead of a positional prefix, andpdaSeedNodeFromAnchorV01returnsundefinedfor seeds that cannot be expressed statically.- instructionAccountNodesFromAnchorV00(accounts, prefix); + instructionAccountNodesFromAnchorV00(accounts, dataFields, { definedTypes, prefix }); - instructionAccountNodesFromAnchorV01(accounts, instructionArguments, prefix); + instructionAccountNodesFromAnchorV01(accounts, dataFields, { definedTypes, prefix }); - pdaSeedNodeFromAnchorV01(seed, instructionArguments, prefix); + pdaSeedNodeFromAnchorV01(seed, dataFields, { definedTypes, prefix });
The same applies to
instructionAccountNodeFromAnchorV00andinstructionAccountNodeFromAnchorV01.Enum variant helpers unified. The
enumEmptyVariantTypeNodeFromAnchorV0x,enumStructVariantTypeNodeFromAnchorV0xandenumTupleVariantTypeNodeFromAnchorV0xhelpers are replaced byenumVariantTypeNodeFromAnchorV00andenumVariantTypeNodeFromAnchorV01, which return anenumVariantTypeNodewith a struct, tuple or nodata.Lossless numbers. Numbers become
integerTypeNodes orfloatTypeNodes, and integer constants become string-encodedintegerValueNodes, so 64- and 128-bit constants are no longer rounded.No program origin. Programs no longer carry an
origin, which v2 removes. - Instruction account
-
#1264
909960fThanks @lorisleiva! - Trim public exports that were only meant for internal use, so the public API only exposes what consumers need.BREAKING CHANGES
@codama/errorsno longer exportssafeCaptureStackTrace. It was unused, even byCodamaError, and is also gone fromcodama, which re-exports it. CallError.captureStackTracedirectly if you need it.@codama/fragments/javascriptno longer exportspreferIncoming. UsemergeImportMapsoraddToImportMap, which apply the same conflict-resolution rule.@codama/dynamic-address-resolutionno longer exportsOPTIONAL_NODE_KINDS. Check the type node kind directly, e.g.isNode(type, ['optionTypeNode', 'remainderOptionTypeNode', 'zeroableOptionTypeNode']).@codama/nodes-from-anchoronly exports its root and program converters. The per-node converters, their options types and the generics helpers are now internal. Convert whole IDLs withrootNodeFromAnchor(orrootNodeFromAnchorV00,rootNodeFromAnchorV01,programNodeFromAnchorV00andprogramNodeFromAnchorV01) and pick the nodes you need from the result. The removed exports are:accountNodeFromAnchorV00,arrayTypeNodeFromAnchorV00,constantNodeFromAnchorV00,definedTypeNodeFromAnchorV00,enumTypeNodeFromAnchorV00,enumVariantTypeNodeFromAnchorV00,errorNodeFromAnchorV00,eventNodeFromAnchorV00,instructionAccountNodeFromAnchorV00,instructionAccountNodesFromAnchorV00,instructionNodeFromAnchorV00,mapTypeNodeFromAnchorV00,optionTypeNodeFromAnchorV00,pdaNodeFromAnchorV00,pdaSeedTypeNodeFromAnchorV00,setTypeNodeFromAnchorV00,structFieldTypeNodeFromAnchorV00,structTypeNodeFromAnchorV00,tupleTypeNodeFromAnchorV00,typeNodeFromAnchorV00andInstructionAccountNodeFromAnchorV00Options.accountNodeFromAnchorV01,arrayTypeNodeFromAnchorV01,constantNodeFromAnchorV01,definedTypeNodeFromAnchorV01,enumTypeNodeFromAnchorV01,enumVariantTypeNodeFromAnchorV01,errorNodeFromAnchorV01,eventNodeFromAnchorV01,instructionAccountNodeFromAnchorV01,instructionAccountNodesFromAnchorV01,instructionNodeFromAnchorV01,optionTypeNodeFromAnchorV01,pdaSeedNodeFromAnchorV01,structFieldTypeNodeFromAnchorV01,structTypeNodeFromAnchorV01,tupleTypeNodeFromAnchorV01,typeNodeFromAnchorV01,unwrapGenericTypeFromAnchorV01,extractGenerics,GenericsV01,InstructionAccountNodeFromAnchorV01OptionsandPdaSeedNodeFromAnchorV01Options.extractPdasFromProgram: useextractPdasVisitorinstead.
- import { accountNodeFromAnchorV01 } from '@codama/nodes-from-anchor'; - const account = accountNodeFromAnchorV01(idl.accounts[0], idl.types, generics); + import { rootNodeFromAnchor } from '@codama/nodes-from-anchor'; + const account = rootNodeFromAnchor(idl).program.accounts?.[0];
@codama/visitors-coreno longer exportsLINKABLE_NODES,getDependenciesandassertNodePathHasProgram. These are also gone from@codama/visitorsandcodama, which re-export it. UsefindProgramNodeFromPathto check that a path has a program, andgetResolvedInstructionInputsVisitorto resolve instruction input dependencies. -
#1260
3ad402aThanks @lorisleiva! - Require Node.js 22.12.0 or later.BREAKING CHANGES
Node.js 20 is no longer supported. Every package now declares
"engines": { "node": ">=22.12.0" }, the first Node.js 22 release that supportsrequire(esm)by default. Node.js 20 reached its end of life in April 2026, and some dependencies (e.g.commander) already require Node.js 22.12.0.
Patch Changes
-
#1260
3ad402aThanks @lorisleiva! - Inline@noble/hashesin CommonJS builds sorequireworks on Node.js versions withoutrequire(esm)support. -
#1248
7f8bedaThanks @lorisleiva! - Fix the instruction discriminators of legacy (v00) IDLs and the error thrown for unknown generic types:- Instruction names containing acronyms now hash to the name Anchor uses, e.g.
setHTTPConfighashesglobal:set_http_configinstead ofglobal:set_h_t_t_p_config. - Shank instruction discriminators below 16 are zero-padded to a full byte, e.g.
0ainstead ofa. - References to an unknown generic type in current (v01) IDLs throw a
CODAMA_ERROR__ANCHOR__GENERIC_TYPE_MISSINGerror instead of aTypeError.
- Instruction names containing acronyms now hash to the name Anchor uses, e.g.
-
Updated dependencies [
cedeb1e,1f0fb88,3f76a7f,e1cce0d,64d52eb,e92df74,7f8beda,7f8beda,cedeb1e,7f8beda,909960f,3f76a7f,bb09077,bb09077,3ad402a,7f8beda,7f8beda,b869cef,7f8beda,7f8beda,08d72e7,7f8beda]:- @codama/visitors@2.0.0-rc.0
- @codama/errors@2.0.0-rc.0
- @codama/fragments@2.0.0-rc.0
- @codama/nodes@2.0.0-rc.0