feat(icrc-ledger-types): add ICRC-122 block schema validators#9586
feat(icrc-ledger-types): add ICRC-122 block schema validators#9586
Conversation
There was a problem hiding this comment.
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
icrc122module with schema validators and constants for122mint/122burnand152mint/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.
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>
0f69c20 to
cac4592
Compare
There was a problem hiding this comment.
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.
mbjorkqvist
left a comment
There was a problem hiding this comment.
Thanks @bogwar, LGTM! I just have a couple of minor comments.
| /// 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)) | ||
| } |
There was a problem hiding this comment.
Is this useful? It currently doesn't seem to be used anywhere.
There was a problem hiding this comment.
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.
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>
Summary
icrc122module inpackages/icrc-ledger-types/with block schema validators for122mint/122burnblock typesbtypeconstants (122mint,122burn) andmthdconstants (152mint,152burn)btype/legacy rulesThis is PR 1 of 6 for ICRC-122/152 (Privileged Mint/Burn). Types only — no
Operationenum changes, no.didchanges, no CandidTransactionchanges.Test plan
🤖 Generated with Claude Code