Skip to content

Release package 2.0.0-rc.0 - #177

Open
codama-releases[bot] wants to merge 1 commit into
mainfrom
knope-release/main
Open

codama-releases[bot] wants to merge 1 commit into
mainfrom
knope-release/main

Conversation

@codama-releases

@codama-releases codama-releases Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

This PR was opened by the release workflow. Merging it publishes every crate of the workspace as 2.0.0-rc.0 and creates the matching GitHub release.

Breaking Changes

Add Text, Integer and Decimal, and rewrite Docs for spec v2

Docs is now an optional Text (a plain string or a textNode) and serialises as a single string. Integer and Decimal hold spec v2 numeric literals as canonical base-10 strings, with Decimal::from(f64) producing the same digits as JavaScript. Node gains Transform and Text, TypeNode gains Integer, Float, FixedPoint and Duration, and the v1 nesting machinery (NestedTypeNode, #[nestable_type_node], the wrapper type nodes, the generic NodeUnion derive) is removed.

Add unit(...) number displays

display(unit("SOL")), or display = unit(...) inline on a number type, labels a number with a unit without scaling it, and the unit can also be a public key such as a mint address. Floats and fixed points take only this display, so an amount(...) display on them is now an error pointing to unit(...), and an amount(...) display without decimals suggests either.

Build identifiers, paths, namespaces and decimals from string literals

Identifier, Path, Namespace and Decimal convert from string literals, so constructors take them directly, e.g. AccountNode::new("my_account", data) or FieldDiscriminatorNode::new("header.kind", 0). A literal that breaks the spec grammar panics; parse any other string with str::parse or TryFrom<String>, which return the error instead.

Build spec v2 instruction data and defaults from Rust code

The fields of an instruction are now collected into a single data struct instead of a list of arguments, and a contextual default such as #[codama(default_value = payer)] is injected into its field from a provides entry on the instruction. Rust integer and float types map to integerTypeNode and floatTypeNode. Using field(...) on a tuple struct or variant is now an error, and an enum_discriminator name must be a valid identifier.

Emit transforms from wrapper attributes

fixed_size(...), size_prefix(...), pre_offset(...), post_offset(...), sentinel(...), hidden_prefix(...) and hidden_suffix(...) keep their syntax, but they now attach transforms to the type they wrap, innermost first, rather than producing wrapper nodes in the IDL. They can also wrap a link(...), and the prefix of size_prefix(...) must be an integer(...).

Fail when modules or plugins describe the same item differently

When several modules describe the same program, two nodes of the same kind and identifier with different content, or two plugins with the same namespace and different payloads, are now an error instead of one silently replacing the other. Identical duplicates still merge into one. A linked PDA seed that matches no field is also an error.

Number enum variants like Rust and apply directives where they were ignored

  • The variants following an explicit discriminant carry the discriminator Rust gives them, e.g. Frozen in enum Status { Active = 5, Frozen } is 6 rather than its index. A discriminant that is not an unsigned integer literal fitting a u32 is an error instead of being ignored.
  • The declare_id! and codama_program! macros of a crate no longer leak into the other crates of a Codama::load_all, and declare_id! given a constant no longer sets the public key to the name of that constant.
  • A program(...) directive applies on a mod file; declaration, at the top of a file (#![codama(program(...))]) and at the top of the crate root, where the declaration wins over the file. One on a variant or field is an error.
  • Type modifiers such as fixed_size apply to type aliases, and an exported type alias that does not resolve to a type is an error.
  • An item deriving several Codama items, such as #[derive(CodamaType, CodamaAccount)], is an error, as the derives would conflict. Attributes::has_any_codama_derive is replaced by Attributes::codama_derives.

Stop dropping or misreading attributes

  • The docs of a field(...) type reach the IDL instead of being parsed and dropped.
  • skip rejects an argument, so #[codama(skip = false)] is an error rather than a skip, and option(..., fixed(false)) is an error rather than a fixed option.
  • Attributes behind any cfg_attr condition, such as #[cfg_attr(not(target_os = "solana"), codama(...))], are read like those behind a feature, as the IDL describes every configuration.
  • An invalid PDA seed reports what a seed can be instead of an internal message.

Flatten Node into one variant per node kind

Node now has one variant per node kind instead of one per category, so Node::Type(RegisteredTypeNode::StructField(field)) becomes Node::StructFieldType(field) and Node::ContextualValue(RegisteredContextualValueNode::Pda(pda)) becomes Node::PdaValue(pda). A new NodeRef enum borrows any node with the same variants, so a tree can be walked without cloning it. Every node and node union converts into Node and NodeRef, and back from Node with try_from. Deserialising a node of an unknown kind now names that kind in the error.

Inject contextual defaults from field(...) and reject ambiguous fields

A contextual default such as default_value = payer written in a field(...) directive on an instruction is now injected through a provides entry, like a default written on a Rust field. Contextual defaults outside an instruction, two fields of a struct whose identifiers share the same camelCase form, and a default_value next to an account(...) directive are now errors instead of being dropped or accepted.

Make CodamaError non-exhaustive

New error variants can now be added in minor releases, so a match on CodamaError outside this crate needs a wildcard arm.

Merge enum variant types and port value nodes to spec v2

The empty, tuple and struct enum variant types are replaced by a single EnumVariantTypeNode whose optional data can be any type node, and an EnumValueNode payload can now be any value node rather than an EnumValuePayload. Number values split into IntegerValueNode and FloatValueNode. Instruction arguments are referenced with a DataValueNode holding a validated Path, which replaces ArgumentValueNode, and AccountDataValueNode replaces AccountFieldValueNode.

Name the file in filesystem and manifest errors

CodamaError::Filesystem and CodamaError::Manifest now carry the path of the file that could not be accessed or parsed alongside their source, which is also the cause of the error. A bare OS error is replaced by one naming the file:

Could not access `programs/token/src/lib.rs`: No such file or directory (os error 2)

They are no longer built with From, and CodamaError::UnexpectedNode is merged into UnexpectedNodeKind. CodamaError::to_compile_error now emits a compile_error! for every variant rather than nothing for those without a span.

Point attribute errors at their cause

A number in default_value = ... too large or too small for any integer now says so rather than unrecognized value, and a Rust name that yields no valid identifier, such as été, explains why and suggests setting one with identifier = "...". Code matching on these messages needs updating.

Regenerate the nodes from spec v2

Node structs now follow spec v2: every node carries plugins, type nodes carry transforms in place of the v1 wrapper nodes, and NumberTypeNode/NumberValueNode are replaced by IntegerTypeNode, FloatTypeNode, FixedPointTypeNode, DurationTypeNode, IntegerValueNode and FloatValueNode. Named nodes serialise identifier instead of name, nodes are no longer Copy, and the v1-only nodes (argumentValueNode, resolverValueNode, instructionArgumentNode, the three enum variant nodes, amountTypeNode, solAmountTypeNode) are removed.

Reject PDA seeds that would otherwise be dropped

A seed linked to a field by name, such as seed(name = "authority"), now fails with an error asking for an explicit type = ... when the field's Rust type has no Codama type, instead of silently leaving the seed out of the PDA. A nested data(...) path in the seed list of a pda(...) value must also be named explicitly with seed("name", data(...)).

Remove Docs::push

Docs no longer has a push method. Build docs from a Vec<String> or a Text instead, e.g. Docs::from(vec!["First line".to_string()]).

Call the identifiers of directives identifier and parse encodings as bare paths

The name field of AccountDirective, FieldDirective, ProgramDirective, EnumDiscriminatorDirective, CodamaProgramMacro and SeedDirectiveType::Variable is renamed identifier, as it holds an Identifier and the attributes already say identifier = "...". An encoding is written as a bare path everywhere, so discriminator(bytes = "...", encoding = utf8) replaces encoding = "utf8", like string(encoding = utf8) and #[codama(encoding = utf8)] already were, and an invalid one lists the accepted encodings. The assert_type! and sibling test macros are no longer exported. The error for a pda(...) directive expected elsewhere named seed and now names pda. The v1 encoding = "utf8" points to encoding = utf8.

Rename the name field of nodes to identifier

Following spec v2, the 22 nodes that identify themselves by a name now expose that name as identifier rather than name, and the HasName trait becomes HasIdentifier with an identifier() method. In Rust code, this affects plugins and any code constructing or reading nodes directly.

Replace amount and sol_amount with fixed_point, and add duration and ticks

amount(number(u64), 6, "USDC") becomes fixed_point(integer(u64), scale = 6, unit = "USDC"), with an optional base, and sol_amount(...) becomes fixed_point(..., scale = 9, unit = "SOL"). integer(...) and float(...) accept a unit, date_time(...) accepts ticks_per_second, and the new duration(...) type describes time spans. Using amount(...) or sol_amount(...) fails with a hint pointing to the replacement.

Replace wrapper type nodes with transforms

Layout modifiers no longer wrap the type they apply to: FixedSizeTypeNode, SizePrefixTypeNode, PreOffsetTypeNode, PostOffsetTypeNode, SentinelTypeNode, HiddenPrefixTypeNode and HiddenSuffixTypeNode become the *TransformNodes of spec v2, attached to any type node or defined type link with add_transform, e.g. StringTypeNode::utf8().add_transform(FixedSizeTransformNode::new(42)). Floats move to the new FloatTypeNode, FixedPointTypeNode and DurationTypeNode are added, and DateTimeTypeNode now wraps an IntegerTypeNode.

Turn the variants of accounts, events and instructions into items the same way

The visitors turning the variants of a CodamaAccounts, CodamaEvents or CodamaInstructions enum into program items share one way of numbering variants and reading their data, so tuple variants are accepted everywhere, including for accounts, and a default_value on a tuple item reaches the field it becomes, as it already did for instructions. A discriminator that would overflow a u32 is an error. Duplicate field identifiers are reported by the validator, once against their path, rather than also by the visitors; CombineTypesVisitor no longer exposes its fields, including the misspelled get_nammed_field and get_unnammed_field: configure it with new, strict, allowing_contextual_default_values and with_named_field.

Simplify enum value constructors and directive checks

EnumValueNode now has two constructors: new builds a variant without data, and with_value builds a variant with any value as its data. The previous empty, fields and tuple constructors are removed. Attributes::has_codama_attribute is replaced by Attributes::has, which takes a directive filter such as SkipDirective::filter instead of a directive name. Invalid identifiers in attributes now point at the string itself. Variable seeds are now validated when the attribute is parsed, so SeedDirectiveType::Variable holds an Identifier.

Split number into integer and float, and replace argument with field and data

Write integer(...) or float(...) wherever you used number(...), including in size = ... and prefix = .... Instruction arguments are declared as data fields with field(...), values that read from instruction data use data(...), which also accepts nested paths such as data("config.fees[0]"), and remaining_accounts(argument("x"), ...) becomes remaining_accounts("x", ...). Amount displays now require decimals, and enum variants accept any payload type. Using a removed spelling fails with a hint pointing to its replacement.

Mark every union and enum as non-exhaustive and name inline union variants after their node

Every generated union and enumeration, such as ValueNode, TransformNode, IntegerFormat and IsSigner, as well as TypeNode and RegisteredTypeNode, is now #[non_exhaustive] like Node, so a member that a minor spec version adds is not a breaking change. Matches outside of codama-nodes need a wildcard arm. The variants of the inline unions keep the whole name of their node like Node does, so PdaSeedValueValue::Account is now PdaSeedValueValue::AccountValue, and RegisteredContextualValueNode::Account is RegisteredContextualValueNode::AccountValue. The main union of each category still implies its category word, e.g. ValueNode::Integer and LinkNode::Account.

Start major 2

Release candidates of major 2 publish from main while it is in development. The stable release follows the ecosystem-wide release process.

Update count, discriminator and display node constructors for spec v2

FieldDiscriminatorNode now points at its field with a Path, validated against the spec path grammar like the path of dataValueNode and accountDataValueNode, so a nested field such as header.kind can serve as a discriminator. AmountNumberDisplayNode::new requires decimals and no longer implements Default, and PrefixedCountNode::new takes an IntegerTypeNode. New constructors are available for SentinelCountNode, UnitNumberDisplayNode and ValueLabelDisplayNode, along with IntegerTypeNode::{le, be} and IntegerValueNode::new.

Update program, account and instruction nodes for spec v2

Instructions describe their payload with a single optional data type node, plus an optional return_data, instead of a list of arguments. Accounts accept any type node as their data, remaining accounts are identified by name rather than carrying an argument or resolver value, and byte deltas use the spec v2 value nodes. Programs no longer have an origin, error and status messages accept rich text, and plugin namespaces are validated, so invalid ones are rejected when deserialising.

Use snake_case identifiers and replace name = ... with identifier = ...

Identifiers derived from Rust code are now snake_case (MyAccount → my_account, HTTPServer → http_server), whilst identifiers written in attributes, such as field("x", ...), pda("...") or identifier = "...", are kept exactly as written and must match the spec identifier grammar. References must therefore use the derived spelling, e.g. pda("my_pda") for struct MyPda. The name = "..." key becomes identifier = "...", with a hint when the old key is used. In the Rust API, CamelCaseString is replaced by Identifier, which validates its value.

Validate cyclic defined types without a finite value

Codama::get_idl now fails when a defined type links back to itself such that every value nests another one, e.g. loop = struct { next: link(loop) } or alias = link(alias), since no codec can encode or decode it. Cycles with a way out, such as an option, an enum with another variant or a collection that may be empty, are still accepted. codama-visitors-core gains is_defined_type_cyclic, has_defined_type_finite_value, get_defined_type_links_visitor and get_has_finite_value_visitor, like in the JavaScript library.

Validate the PDA, instruction and instruction account links of the IDL

Codama::get_idl now also fails when a PDA, instruction or instruction account link points to no node of its program, e.g. #[codama(pda = "vualt")]. Links naming a program that is not in the IDL point outside of it, such as the PDA of the associated token program, so they are not checked, and neither are account and defined type links to such programs.

Validate paths, contextual values, interpolated intents and value labels

Codama::get_idl now also fails when a field discriminator path does not point to a struct field of the data it identifies, when a data, account or account data value does not resolve within its instruction, when an interpolated intent has an invalid or unresolvable placeholder, and when a value label is not a concrete value of the type of its field. codama-visitors-core gains resolve_type_path and is_value_node_of_type, and codama-nodes gains Path::segments, parse_interpolated_intent and print_interpolated_intent, like in the JavaScript library.

Validate the default values of instruction inputs

Codama::get_idl now also fails when the default values of an instruction depend on each other in a cycle or on an account or data field that the instruction does not have, when a data field defaults to the bump of an account that may be a signer, and when an injected value is neither provided nor given a fallback. codama-visitors-core gains get_resolved_instruction_inputs and get_instruction_data_fields, like in the JavaScript library. The former fails with a ResolveInstructionInputsError that keeps the node paths and the dependency involved, so callers can match on them, and converts into a CodamaError for ?.

Validate the IDL with codama-validators

A new codama-validators crate lists the validation items of a Codama tree, like @codama/validators in the JavaScript library: missing identifiers, identifier collisions, links to missing nodes, programs without a public key, and more. Codama::get_idl and Codama::get_node now run it and fail with FailedToValidateNode, which lists every item, when any item is an error. In particular, a crate must now declare its program address, for example with [package.metadata.solana] program-id = "...". The CLI prints the message of an error rather than its debug representation.

Walk koroks with walk_* functions, like syn::visit_mut

Every KorokVisitor method now defaults to the matching walk_* function, such as walk_struct(visitor, korok), which a visitor handling a korok itself calls to keep walking. KorokVisitor::visit_children and KorokVisitable::get_children, which walked a parallel list of children, are removed; walk_korok_mut walks the children of any KorokMut. KorokMut gains the Impl variant it lacked, so UniformVisitor and DebugVisitor visit impl blocks, and ComposeVisitor forwards every method to its visitors, including visit_const and visit_type_alias, which it used to walk on its own. The KorokPlugin trait and its phases are documented.

Features

Add the codama-visitors-core crate

A new codama-visitors-core crate visits and transforms Codama nodes, like @codama/visitors-core in the JavaScript library. A Visitor returns a value for each node, with IdentityVisitor, MergeVisitor and VoidVisitor as bases and adapters such as extend, tap, map, non_null and record_node_stack to build on them. NodeStack, NodePath and LinkableDictionary track the visited path and resolve link nodes. NodeRef gains children, map_children and identifier, and converts back into a reference to its node with try_from.

Emit float values for numbers written at float positions

A whole number such as default_value = 1 on a float field, constant, discriminator or PDA seed now produces a floatValueNode rather than an integerValueNode, following links to find the type, so the output matches spec v2 and @codama/upgrade. The default plugin runs this pass with TransformIntegersToFloatsVisitor, and its logic is available as transform_integers_to_floats(&root), so a plugin that adds values later can run it again.

List the expected node kinds in errors

Nodes and node unions now implement NodeKinds, whose KINDS constant lists the node kinds they can hold, like the *_KINDS constants of the JavaScript library. ProvidedScope uses it to name the expected kinds when a resolved value has the wrong kind, and reports a fallback of the wrong kind with a new UnexpectedNodeKind error.

Resolve injected values with ProvidedScope

codama-visitors-core gains ProvidedScope, which holds the providedNodes visible at a point of the tree and resolves the injectedValueNodes found there, like in the JavaScript library. The record_provided_scope adapter keeps it in sync with a visit, and get_provided_scope_from_path builds it from the instructions of a path.

Fixes

Emit node attributes in spec declaration order

Nodes now serialise their attributes in the order the spec declares them, followed by plugins, which matches the IDLs produced by @codama JS. Only the order of keys in the JSON changes, not its content.

Keep defaults and plugins that were silently dropped

An instruction field renamed with type = field("...", ...) now keeps its default_value, and the plugins set on a program by several modules are now merged by namespace rather than only keeping those of the first module.

Report conflicting PDAs of account variants against their enum

Variants of a #[derive(CodamaAccounts)] enum sharing an identical PDA now keep it once rather than adding it to the program for each variant, and variants describing a PDA of the same identifier differently fail with an error pointing at the enum that declares them.

Pin the crates to each other and declare the minimum Rust version

The crates of the workspace now depend on each other at their exact version, so a release candidate never resolves to a sibling from another candidate, and they declare Rust 1.83 as their minimum supported version. codama-rs generate-idl -o <file> ends the file with a newline, like its output on stdout.

Report unrecognized attributes consistently

An unknown key in account(...) or account_bump(...), such as account(banana = "authority"), now fails with unrecognized attribute like every other directive, rather than only 'identifier' attribute supported. Within integer(...) and float(...), the error now underlines the whole unrecognized attribute, such as foo = 42 rather than foo alone, and a value that is not a path, such as integer(u64, "slots"), also fails with unrecognized attribute rather than expected a path.

@codama-releases
codama-releases Bot force-pushed the knope-release/main branch 29 times, most recently from 99b8461 to 12b463e Compare November 12, 2026 11:16
@codama-releases
codama-releases Bot force-pushed the knope-release/main branch 15 times, most recently from 3eb2f9c to 41a8f75 Compare November 26, 2026 14:19
@codama-releases
codama-releases Bot force-pushed the knope-release/main branch 5 times, most recently from 1827e7c to 684c3e2 Compare November 27, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants