feat(ic-icrc-rosetta): add ICRC-122 AuthorizedMint/AuthorizedBurn Rosetta support#9751
feat(ic-icrc-rosetta): add ICRC-122 AuthorizedMint/AuthorizedBurn Rosetta support#9751bogwar wants to merge 3 commits intoicrc-122-1-typesfrom
Conversation
There was a problem hiding this comment.
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
AuthorizedMintandAuthorizedBurnvariants to theIcrcOperationenum and supporting infrastructure - Implemented block-to-operation conversion, account balance updates, and database storage for ICRC-122 operations
- Added new
AuthorizedOperationMetadatatype 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}" |
There was a problem hiding this comment.
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.
| "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}" |
| } | ||
|
|
||
| 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")? { |
There was a problem hiding this comment.
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.
| 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")? { |
There was a problem hiding this comment.
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.
…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>
993b51b to
f82f554
Compare
Summary
AuthorizedMintandAuthorizedBurnvariants toIcrcOperationin Rosettablocks_strategynow that Rosetta handles them/block,/account/balance, and/search/transactionsendpointsTest plan
test_authorized_mint_and_burn_122): injects minimal ICRC-122 and full ICRC-152 blocks viaicrc3_test_ledger, verifies balances, block operations (type, account, amount, metadata), and search transactions through a running Rosetta instance🤖 Generated with Claude Code