Skip to content

feat(icrc-ledger-types): add ICRC-122 block schema validators#9586

Draft
bogwar wants to merge 3 commits intomasterfrom
icrc-122-1-types
Draft

feat(icrc-ledger-types): add ICRC-122 block schema validators#9586
bogwar wants to merge 3 commits intomasterfrom
icrc-122-1-types

Conversation

@bogwar
Copy link
Copy Markdown
Contributor

@bogwar bogwar commented Mar 25, 2026

Summary

  • Adds icrc122 module in packages/icrc-ledger-types/ with block schema validators for 122mint/122burn block types
  • Defines btype constants (122mint, 122burn) and mthd constants (152mint, 152burn)
  • Includes both permissive (ICRC-122) and strict (ICRC-152) validation modes
  • General block validation enforcing btype/legacy rules

This is PR 1 of 6 for ICRC-122/152 (Privileged Mint/Burn). Types only — no Operation enum changes, no .did changes, no Candid Transaction changes.

Test plan

  • Types-only change with no new runtime behavior — verified by existing test suites passing
  • Schema validators are tested via unit tests in the module

🤖 Generated with Claude Code

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial ICRC-122/152 (privileged mint/burn) plumbing across the ledger types, ICRC-1 ledger implementation, and downstream consumers by introducing new block schemas and new Operation variants for authorized mint/burn.

Changes:

  • Added icrc122 module with schema validators and constants for 122mint/122burn and 152mint/152burn.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bogwar bogwar requested a review from mbjorkqvist March 27, 2026 11:09
Add block type schema validators for the ICRC-122 standard
(AuthorizedMint/AuthorizedBurn block types). This includes:

- New `icrc122` module with `btype` and `mthd` constants
- Schema validation functions for `122mint` and `122burn` blocks
- Permissive (ICRC-122) and strict (ICRC-152) validation modes
- General block validation enforcing `btype`/legacy rules

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bogwar bogwar force-pushed the icrc-122-1-types branch from 0f69c20 to cac4592 Compare March 27, 2026 16:29
@bogwar bogwar requested a review from Copilot March 27, 2026 16:29
@bogwar bogwar changed the title feat(icrc-ledger-types): add ICRC-122 block schemas and AuthorizedMint/AuthorizedBurn feat(icrc-ledger-types): add ICRC-122 block schema validators Mar 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@mbjorkqvist mbjorkqvist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bogwar, LGTM! I just have a couple of minor comments.

Comment on lines +157 to +164
/// Validate if a block is compatible with any ICRC-122 schema (mint or burn).
pub fn validate(block: &Value) -> Result<(), ValuePredicateFailures> {
use std::sync::Arc;
or(vec![
Arc::new(|v| validate_mint(&v)),
Arc::new(|v| validate_burn(&v)),
])(Cow::Borrowed(block))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this useful? It currently doesn't seem to be used anywhere.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It follows the same pattern as icrc3::schema::validate — it will be used in the ledger integration tests (branch 4) to verify that produced blocks conform to the ICRC-122 schema, same way icrc3::schema::validate is used in rs/ledger_suite/tests/sm-tests/src/lib.rs.

bogwar and others added 2 commits March 30, 2026 12:46
Extract shared block_validator helper to eliminate code duplication
between validate_mint/validate_152_mint and validate_burn/validate_152_burn.
The only difference is the strictness of caller/mthd fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants