feat(icrc1): add ICRC-123 freeze Operation variants, index-ng, and .did updates#9533
feat(icrc1): add ICRC-123 freeze Operation variants, index-ng, and .did updates#9533bogwar wants to merge 1 commit intoicrc-123-1-typesfrom
Conversation
…id updates - Add 4 Operation variants: FreezeAccount, UnfreezeAccount, FreezePrincipal, UnfreezePrincipal - Add account/principal fields to FlattenedTransaction for CBOR serialization - Update TryFrom/From conversions for new block types - Freeze ops are no-ops in Transaction::apply() (no balance impact) - Update index-ng to handle freeze ops (no balance tracking) - Update archive.did, index-ng.did, ledger.did with freeze types - Update exhaustive Operation matches in test_utils, in_memory_ledger - Add minimal rosetta match arms for new Operation variants 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-123 freeze/unfreeze operations to the ledger suite. The PR extends the Operation enum with four new variants (FreezeAccount, UnfreezeAccount, FreezePrincipal, UnfreezePrincipal), adds serialization/deserialization support through the FlattenedTransaction struct, implements endpoint conversion in Block ↔ Transaction conversions, and adds appropriate stubs for Rosetta support. The freeze operations are correctly treated as non-balance-affecting operations throughout the codebase.
Changes:
- Added four freeze/unfreeze operation variants to the
Operationenum inrs/ledger_suite/icrc1/src/lib.rs - Extended
FlattenedTransactionwithaccountandprincipalfields to support serialization - Implemented conversions between
Operation/TransactionandFlattenedTransactionfor all freeze variants - Added endpoint conversion support in
rs/ledger_suite/icrc1/src/endpoints.rsmapping freeze operations toFreezeAccountActionandFreezePrincipalAction - Updated all exhaustive pattern matches across the codebase to include the four new operation variants
- Updated error message in Rosetta tests from "ICRC-124 operations" to "Management operations" to reflect inclusion of ICRC-123 operations
- Added
unimplemented!()stubs for freeze operations in Rosetta with notes on follow-up PR
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
rs/ledger_suite/icrc1/src/lib.rs |
Added four new Operation variants with full serialization/deserialization support and proper handling in apply_transaction as no-ops |
rs/ledger_suite/icrc1/src/endpoints.rs |
Added Block→Transaction conversion for all four freeze operations |
rs/ledger_suite/icrc1/index-ng/src/main.rs |
Updated pattern matches to handle freeze operations as non-balance-affecting |
rs/ledger_suite/icrc1/test_utils/src/lib.rs |
Updated test utilities to properly handle freeze operations as no-ops in balance tracking |
rs/ledger_suite/test_utils/in_memory_ledger/src/lib.rs |
Updated in-memory ledger to handle freeze operations as no-ops |
rs/rosetta-api/icrc1/src/common/storage/types.rs |
Added unimplemented! stub with follow-up PR note |
rs/rosetta-api/icrc1/src/construction_api/services.rs |
Updated test to include new operation variants with corrected error message |
rs/rosetta-api/icrc1/tests/system_tests.rs |
Updated exhaustive match arm to include four new operation variants |
rs/rosetta-api/icrc1/tests/multitoken_system_tests.rs |
Updated exhaustive match arm to include four new operation variants |
All changes are consistent with the implementation pattern established by ICRC-124 management operations (Pause, Unpause, Deactivate). The implementation correctly:
- Imports constants from
icrc_ledger_types - Uses existing action types (
FreezeAccountAction,FreezePrincipalAction) - Treats freeze operations as non-balance-affecting throughout the codebase
- Provides clear unimplemented stubs with notes about follow-up work
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
FreezeAccount,UnfreezeAccount,FreezePrincipal,UnfreezePrincipalvariants toOperationenum with CBOR encoding/decoding inTransactionOperation↔GetTransactionsResponse) with properbtypemapping for all 4 freeze/unfreeze block typesStacked on #9530.
Test plan
🤖 Generated with Claude Code