feat(ic-icrc1): add ICRC-122 AuthorizedMint/AuthorizedBurn candid types, index-ng, and .did support#9694
feat(ic-icrc1): add ICRC-122 AuthorizedMint/AuthorizedBurn candid types, index-ng, and .did support#9694bogwar wants to merge 10 commits intoicrc-122-1-typesfrom
Conversation
…es, index-ng, and .did support - Add AuthorizedMint/AuthorizedBurn Candid structs and Transaction fields - Replace panic stubs with real implementations in index-ng (balance changes and account extraction), endpoints (Block-to-Transaction conversion), test_utils, in_memory_ledger, and Transaction::apply - Update ledger.did, archive.did, and index-ng.did with new types Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds support for ICRC-122 AuthorizedMint and AuthorizedBurn transaction types to the ledger system. The changes include adding new Candid structs and transaction fields in icrc-ledger-types, replacing panic stubs with real implementations for balance operations across multiple modules (index-ng, endpoints, lib.rs, test_utils, in_memory_ledger), and updating the .did files with the new types.
Changes:
- Add AuthorizedMint and AuthorizedBurn Candid structs and fields to the Transaction type in icrc-ledger-types
- Implement balance credit/debit operations for authorized mints/burns in index-ng, lib.rs, and test utilities
- Add Block-to-Transaction conversion support for the new operation types in endpoints
- Update ledger.did, archive.did, and index-ng.did with AuthorizedMint and AuthorizedBurn type definitions
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/icrc-ledger-types/src/icrc3/transactions.rs | Adds AuthorizedMint/AuthorizedBurn structs, new constants, Transaction fields, and helper methods |
| rs/ledger_suite/icrc1/src/endpoints.rs | Implements Block-to-Transaction conversion for AuthorizedMint/AuthorizedBurn operations |
| rs/ledger_suite/icrc1/src/lib.rs | Implements balance operations (mint/burn) for authorized operations |
| rs/ledger_suite/icrc1/test_utils/src/lib.rs | Adds balance credit/debit and account validity tracking for authorized operations |
| rs/ledger_suite/test_utils/in_memory_ledger/src/lib.rs | Implements process_mint/process_burn for authorized operations |
| rs/ledger_suite/icrc1/index-ng/src/main.rs | Implements balance changes and account extraction for authorized operations |
| rs/ledger_suite/icrc1/ledger/ledger.did | Adds AuthorizedMint/AuthorizedBurn type definitions |
| rs/ledger_suite/icrc1/archive/archive.did | Adds AuthorizedMint/AuthorizedBurn type definitions |
| rs/ledger_suite/icrc1/index-ng/index-ng.did | Adds AuthorizedMint/AuthorizedBurn type definitions |
| rs/ledger_suite/icrc1/index-ng/tests/tests.rs | Updates test Transaction initialization with new fields |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…izedBurn Candid types
ICRC-122 block schema defines tx fields as {mthd, to/from, amt, caller,
reason} — memo and created_at_time are not part of the standard. Remove
them from the Candid structs, endpoint conversion, and .did files.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- CBOR round-trip: encode/decode preserves all fields and btype - Hash stability: generic block hash matches encoded block hash - Candid conversion: Block→Transaction produces correct kind and fields - Schema validation: blocks with caller/mthd pass ICRC-152 validators, blocks without them pass ICRC-122 but fail ICRC-152 - Transaction::apply: AuthorizedMint credits, AuthorizedBurn debits, insufficient balance fails - Proptest: extend operation_strategy to generate AuthorizedMint/AuthorizedBurn - Fix btype in blocks_strategy for AuthorizedMint/AuthorizedBurn - Fix schema: use is_more_or_equal_to(0) for amt to accept Nat64 from CBOR decoder (same approach as ts field) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…er ICRC-152 ICRC-152 canonical tx mapping includes created_at_time as a tx field (used for deduplication). Add it back to Candid structs, endpoint conversion, .did files, and schema validators. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…CBOR encoding The FlattenedTransaction serializes created_at_time as "ts" in CBOR. Update schema validators to check for "ts" inside tx (matching what the encoder produces), make it required in strict (ICRC-152) mode, and fix test helpers to pass created_at_time for ICRC-152 blocks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ls in sns and nervous_system tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… Rosetta support The blocks_strategy is used by Rosetta proptests which still have panic stubs for these variants. Comment out the new strategies until Rosetta PR implements real handling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ilders Add BlockBuilder::authorized_mint() and BlockBuilder::authorized_burn() methods for constructing ICRC-122 blocks as ICRC3Value. These can be used with the icrc3_test_ledger to test index-ng and Rosetta integration with the new block types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rn via icrc3_test_ledger Test the full pipeline: load ICRC-122 blocks into the test ledger, sync index-ng, and verify: - Balances are correct (authorized mint credits, authorized burn debits) - get_account_transactions returns correct kind and operation fields - Minimal ICRC-122 blocks (no caller/mthd) are indexed correctly Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
AuthorizedMint/AuthorizedBurnCandid structs andTransactionfields inicrc-ledger-typesBlock-to-TransactionconversionTransaction::applybalance operationsledger.did,archive.did, andindex-ng.didwith new typesmemo, includecreated_at_timeis_more_or_equal_to(0)foramtto acceptNat64from CBOR decoder; addtx.ts(created_at_time) as required in strict (ICRC-152) modeBlockBuilder::authorized_mint()andBlockBuilder::authorized_burn()for constructing ICRC-122 test blocksbtypeinblocks_strategyforAuthorizedMint/AuthorizedBurnTest plan
Unit tests (
rs/ledger_suite/icrc1/tests/tests.rs)btypeset to"122mint"/"122burn"Block→Transactionproduces correctkind, populates the right struct with correct fields (includingcreated_at_time), all other operation fields areNonecaller,mthd, andts(created_at_time) passvalidate_152_mint/validate_152_burncaller/mthd/tspass permissivevalidate_mint/validate_burnbut fail strict ICRC-152 validatorsUnit tests (
rs/ledger_suite/icrc1/ledger/src/tests.rs)Integration tests (
rs/ledger_suite/icrc1/index-ng/tests/tests.rs)kind("122mint"/"122burn") and correct operation fields for authorized operationsProptest
operation_strategy(currently disabled pending Rosetta support — Rosetta proptests useblocks_strategyand would hit panic stubs)🤖 Generated with Claude Code