Skip to content

feat(ic-icrc-rosetta): add ICRC-122 AuthorizedMint/AuthorizedBurn Rosetta support#9751

Draft
bogwar wants to merge 3 commits intoicrc-122-1-typesfrom
icrc-122-4-rosetta
Draft

feat(ic-icrc-rosetta): add ICRC-122 AuthorizedMint/AuthorizedBurn Rosetta support#9751
bogwar wants to merge 3 commits intoicrc-122-1-typesfrom
icrc-122-4-rosetta

Conversation

@bogwar
Copy link
Copy Markdown
Contributor

@bogwar bogwar commented Apr 7, 2026

Summary

  • Add AuthorizedMint and AuthorizedBurn variants to IcrcOperation in Rosetta
  • Implement block-to-operation conversion, storage operations, and data API support for ICRC-122 block types
  • Re-enable AuthorizedMint/AuthorizedBurn in proptest blocks_strategy now that Rosetta handles them
  • Add proptest strategies for AuthorizedMint/AuthorizedBurn round-trip codec tests
  • Add storage unit tests for store/read and balance updates of authorized operations
  • Add system test verifying authorized mint/burn through Rosetta /block, /account/balance, and /search/transactions endpoints

Test plan

  • Proptest round-trip: IcrcOperation ↔ BTreeMap ↔ IcrcOperation for both new operation types
  • Storage tests: store/read authorized mint/burn blocks, verify balance credit/debit
  • System test (test_authorized_mint_and_burn_122): injects minimal ICRC-122 and full ICRC-152 blocks via icrc3_test_ledger, verifies balances, block operations (type, account, amount, metadata), and search transactions through a running Rosetta instance

🤖 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

This pull request adds support for ICRC-122 AuthorizedMint and AuthorizedBurn operation types to the Rosetta API. The changes enable the Rosetta system to read and represent these new operation types from blocks, convert them between various format representations, update account balances correctly, and support searching transactions containing these operations. Additionally, the proptest blocks_strategy is re-enabled to generate these operation types now that Rosetta can handle them.

Changes:

  • Added AuthorizedMint and AuthorizedBurn variants to the IcrcOperation enum and supporting infrastructure
  • Implemented block-to-operation conversion, account balance updates, and database storage for ICRC-122 operations
  • Added new AuthorizedOperationMetadata type to handle metadata specific to authorized operations
  • Extended data API services to support searching transactions with authorized operations
  • Re-enabled AuthorizedMint/AuthorizedBurn in the proptest blocks_strategy
  • Updated system tests to properly handle the new operation types

Reviewed changes

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

Show a summary per file
File Description
rs/rosetta-api/icrc1/src/common/storage/types.rs Added AuthorizedMint and AuthorizedBurn variants to IcrcOperation enum, implemented conversion from ic_icrc1 operations, and block parsing
rs/rosetta-api/icrc1/src/common/types.rs Added AuthorizedMint and AuthorizedBurn to OperationType enum and created AuthorizedOperationMetadata struct
rs/rosetta-api/icrc1/src/common/utils/utils.rs Implemented rosetta_core_operations_to_icrc1_operation and icrc1_operation_to_rosetta_core_operations for authorized operations
rs/rosetta-api/icrc1/src/common/storage/storage_operations/mod.rs Added balance update and database storage handling for authorized operations
rs/rosetta-api/icrc1/src/data_api/services.rs Extended transaction search to include authorized operations
rs/rosetta-api/icrc1/src/construction_api/utils.rs Added proper error handling for authorized operations (not supported in construction)
rs/rosetta-api/icrc1/src/construction_api/services.rs Updated test to skip authorized operations
rs/rosetta-api/icrc1/tests/system_tests.rs Updated test to skip authorized operations (similar to Mint/Burn)
rs/rosetta-api/icrc1/tests/multitoken_system_tests.rs Updated test to skip authorized operations
rs/ledger_suite/icrc1/test_utils/src/lib.rs Re-enabled AuthorizedMint and AuthorizedBurn in operation strategy generation

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

}
found => {
bail!(
"Expected field 'op' to be 'burn', 'mint', 'xfer' or 'approve' but found {found}"
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The error message indicates "Expected field 'op' to be 'burn', 'mint', 'xfer' or 'approve' but found {found}" but the code now also handles BTYPE_122_MINT and BTYPE_122_BURN block types via their constants. The error message should be updated to reflect that these block types are also supported.

Suggested change
"Expected field 'op' to be 'burn', 'mint', 'xfer' or 'approve' but found {found}"
"Expected field 'op' to be 'burn', 'mint', 'xfer', 'approve', '{BTYPE_122_MINT}' or '{BTYPE_122_BURN}' but found {found}"

Copilot uses AI. Check for mistakes.
}

pub fn build(self) -> anyhow::Result<crate::common::storage::types::IcrcOperation> {
Ok(match self.icrc_operation.context("Icrc Operation type needs to be of type Mint, Burn, Transfer or Approve")? {
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The context error message "Icrc Operation type needs to be of type Mint, Burn, Transfer or Approve" is outdated and no longer describes all supported operation types. It should be updated to include FeeCollector, AuthorizedMint, and AuthorizedBurn.

Suggested change
Ok(match self.icrc_operation.context("Icrc Operation type needs to be of type Mint, Burn, Transfer or Approve")? {
Ok(match self.icrc_operation.context("Icrc Operation type needs to be of type Mint, Burn, Transfer, Approve, FeeCollector, AuthorizedMint or AuthorizedBurn")? {

Copilot uses AI. Check for mistakes.
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 11 out of 11 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

rs/rosetta-api/icrc1/src/common/storage/types.rs:508

  • The error message at line 505-508 states "Expected field 'op' to be 'burn', 'mint', 'xfer' or 'approve'" but now the code also supports 'BTYPE_122_MINT' and 'BTYPE_122_BURN' operations. The error message should be updated to reflect the newly supported operation types.
                found => {
                    bail!(
                        "Expected field 'op' to be 'burn', 'mint', 'xfer' or 'approve' but found {found}"
                    )

rs/rosetta-api/icrc1/tests/system_tests.rs:1546

  • The comment on line 1545-1546 states "Rosetta does not support mint and burn operations" but now also applies to AuthorizedMint and AuthorizedBurn operations. The comment should be updated to reflect this.
                        // Rosetta does not support mint and burn operations
                        // To keep the balances in sync we need to call the ledger agent directly and then go to the next iteration of args with caller

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

Base automatically changed from icrc-122-3-candid-index-ng to icrc-122-1-types April 9, 2026 14:01
bogwar and others added 3 commits April 9, 2026 22:49
…etta support

- Add AuthorizedMint/AuthorizedBurn variants to IcrcOperation and OperationType
- Add AuthorizedOperationMetadata for caller/mthd/reason in Rosetta operations
- Implement balance updates (credit for mint, debit for burn)
- Implement bidirectional Rosetta operation mapping with metadata round-trip
- Construction API: bail for non-constructable privileged operations
- Re-enable AuthorizedMint/AuthorizedBurn in proptest blocks_strategy
- Add compare_blocks test arms for proptest round-trip validation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add proptest strategies for AuthorizedMint/AuthorizedBurn in types.rs
- Fix btype matching in operation/transaction/block codec proptests
- Add storage tests for store/read of authorized mint/burn blocks
- Add balance update tests verifying credit/debit for authorized operations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bogwar bogwar force-pushed the icrc-122-4-rosetta branch from 993b51b to f82f554 Compare April 9, 2026 22:49
@bogwar bogwar requested a review from mbjorkqvist April 10, 2026 00:36
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.

2 participants