-
Notifications
You must be signed in to change notification settings - Fork 7
feat: app manager; asset manager; creator and sender abstractions #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1ccea65 to
a336c4a
Compare
a336c4a to
8e8b4ac
Compare
- Remove duplicate get_application_address function from utils.rs - Replace all usages with Address::from_app_id method from PR #225 - Update imports and function calls across codebase - Add test for Address::from_app_id method - Maintain backward compatibility for functionality Addresses PR comment by neilcampbell about using Address trait approach
- Update Composer to use Arc<AlgodClient> instead of owned AlgodClient - Remove unnecessary dereference-then-clone patterns in AlgorandClient - Fix test files to use Arc pattern correctly - Eliminate 6 unnecessary AlgodClient clones in AlgorandClient constructor - Improve memory efficiency by sharing client instances across components Addresses PR comment by neilcampbell about excessive cloning
- Replace direct TEAL code string usage as cache key with SHA256 hash - Add hash_teal_code() helper method for consistent hashing - Update both compile_teal and get_compilation_result methods - Improve memory efficiency for large TEAL programs - Maintain O(1) cache lookup performance with fixed-size keys Addresses PR comment by neilcampbell about efficient cache key usage
- Add comprehensive documentation to AppInformation fields - Add documentation to BoxName struct fields - Add documentation to ParsedABIReturn struct fields - Improve API documentation for public interfaces Addresses PR comment by neilcampbell about documenting public fields
- Add TODO comments explaining EmptySigner is temporary - Note that dynamic signer resolution will be implemented with AccountManager - Reference TypeScript's getSigner function pattern as target behavior Addresses PR comment by neilcampbell about signer behavior
…port - Change BoxIdentifier type from String to Vec<u8> - Add documentation explaining binary nature of box identifiers - Update get_box_reference method to handle Vec<u8> directly - Add test for binary box identifier handling - Ensure proper support for non-UTF-8 box names Addresses PR comment by neilcampbell about box identifier type correctness
- Remove duplicate asset creation validation from utils sender.rs - Remove duplicate application call validation from utils sender.rs - Update build_asset_create to use AssetConfigTransactionBuilder with validation - Update build_app_call to use ApplicationCallTransactionBuilder with validation - Update composers to handle validation error results properly - Add comprehensive tests for validation error flow - Maintain intentional early validation for payment/asset transfer amounts Addresses PR comment by neilcampbell about leveraging transact crate validation
- Move ABIReturn struct to algokit_abi crate for consistency - Replace ParsedABIReturn with standard ABIReturn throughout codebase - Update method signatures to use Result<Option<ABIReturn>, AppManagerError> - Remove duplicate ABI type definitions - Centralize all ABI types in algokit_abi crate Addresses PR comment #2275622880 about ABI type consistency
- Update AssetOptOutParams to require creator field (remove Option wrapper) - Fix build_asset_opt_out to set close_remainder_to to creator address - Add convenience method asset_opt_out_with_auto_creator for backward compatibility - Update all tests to provide explicit creator addresses - Align Rust behavior with TypeScript/Python implementations Addresses PR comment #2275906304 about type consistency
…atibility - Add get_box_value_from_abi_method and get_box_values_from_abi_method methods - Use ABIMethod parameter instead of ABIType for TS alignment - Return ABIReturn objects instead of just ABIValue for consistency - Maintain backward compatibility with existing ABIType methods - Enable integration with ABIReturn-based workflows from Task 6 Addresses PR comment #2275629959 about using ABI method instead of ABIType
- Replace manual address generation with Address::from_app_id helper - Remove duplicate get_app_address method - Remove unused Sha512_256 import - Maintain consistency with existing Address trait usage pattern Addresses PR comment #2275633627 about using the Address helper function
- Change HashMap keys from String to Vec<u8> in app state structures - Use key_raw (binary data) as HashMap key instead of string representation - Add comprehensive test coverage for binary key handling - Align with TypeScript UInt8Array typing for cross-language consistency - Ensure proper binary data support for non-UTF-8 keys Addresses PR comment #2275729899 about key field deserialization
- Update TealValue.bytes from String to Vec<u8> in algod and indexer clients - Add automatic base64 deserialization using serde_with::base64::Base64 - Remove manual base64 decoding in app_manager since serde handles it automatically - Update test coverage for bytes type handling with binary data - Align with TypeScript UInt8Array typing for cross-language consistency Addresses PR comment #2275733533 about bytes field deserialization
- Remove unrelated duplicate impl From<SendParams> for BuildParams - Keep original impl From<&SendParams> for BuildParams which is actually used - Clean up code organization per Neil's feedback - This duplicate belonged in inner fee coverage PR, not this one Addresses PR comment #2275909098 about unrelated addition
- Rename asset_reconfigure method to asset_config for better consistency - Align with Algorand protocol terminology and other language implementations - Remove TODO comment that requested this rename - Improve public API clarity while maintaining internal implementation Addresses PR comment #2275990103 about function renaming
- Rename asset_reconfigure method to asset_config for consistency - Update function documentation comment accordingly - Align with Task 21 changes in creator.rs for API consistency - Maintain same parameter types and internal implementation Addresses PR comment #2276017888 about companion function renaming
- Add compiled_approval and compiled_clear to SendAppCreateResult - Extract compilation metadata in both app_create and app_create_method - Align Rust behavior with TypeScript/Python implementations - Ensure consistent program bytes return across all app operations - Maintain backward compatibility with additive changes Addresses PR comment #2276031097 about program bytes return behavior
- Remove custom AssetInformation struct in favor of algod_client::models::Asset - Remove custom AccountAssetInformation struct in favor of algod_client::models::AccountAssetInformation - Leverage generator investment: field renaming and base64 deserialization already implemented in algod types - Breaking change: get_by_id() now returns Asset instead of AssetInformation - Breaking change: get_account_information() now returns AccountAssetInformation instead of custom struct - Update all usage sites to work with nested algod type structure (asset.params.*, account_info.asset_holding.*) - Maintain zero functionality loss while eliminating duplicate type definitions - Architecture improvement: direct use of high-quality generated types instead of wrapper abstraction - Aligns with modular building blocks vision - leverage algod client types directly
- Rename AssetOptOutParams.creator → AssetOptOutParams.close_remainder_to - Address Neil's feedback: 'close_remainder_to does feel more correct to me' - Aligns with TypeScript/Python implementations and Algorand protocol semantics - Breaking change: users now explicitly specify close remainder destination - Updated all test usages to use new field name - No functional changes - same validation and transaction building logic - Improves API clarity: users decide where to close remainder funds
36788bc to
920bd7c
Compare
There was a problem hiding this 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 PR introduces minimal versions of the AppManager and AssetManager clients, along with complete implementations of the TransactionSender and TransactionCreator abstractions. These components serve as essential prerequisites for the upcoming app client functionality by providing TEAL compilation, asset management, and enhanced transaction orchestration capabilities.
- Adds minimal AppManager with TEAL compilation, caching, and template processing capabilities
- Adds minimal AssetManager for asset information retrieval and bulk opt-in/opt-out operations
- Implements complete TransactionSender with validation, result processing, and manager coordination
- Implements complete TransactionCreator for building individual transactions with enhanced parameter validation
Reviewed Changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/indexer_client/src/models/teal_value.rs | Updates TealValue to use Vec for bytes field with base64 serde |
| crates/algokit_utils/tests/transactions/sender.rs | Comprehensive test suite for TransactionSender functionality |
| crates/algokit_utils/tests/transactions/creator.rs | Comprehensive test suite for TransactionCreator functionality |
| crates/algokit_utils/tests/clients/asset_manager.rs | Test suite for AssetManager operations |
| crates/algokit_utils/tests/clients/app_manager.rs | Test suite for AppManager TEAL compilation and template processing |
| crates/algokit_utils/tests/clients/algorand_client.rs | Test suite for AlgorandClient initialization and integration |
| crates/algokit_utils/src/transactions/sender.rs | TransactionSender implementation with validation and result processing |
| crates/algokit_utils/src/transactions/creator.rs | TransactionCreator implementation for building individual transactions |
| crates/algokit_utils/src/transactions/sender_results.rs | Rich result types for transaction sending operations |
| crates/algokit_utils/src/clients/asset_manager.rs | AssetManager implementation for asset operations |
| crates/algokit_utils/src/clients/app_manager.rs | AppManager implementation for TEAL compilation and app state management |
| crates/algokit_utils/src/clients/algorand_client.rs | Enhanced AlgorandClient with manager integrations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Remove internal cache method access from tests, focus on behavior validation - Simplify test comments to avoid over-explanation of obvious operations - Remove TypeScript/Python alignment mentions from API documentation - Improve test maintainability by testing public interface rather than internals
| /// Extension trait providing accessor methods for Transaction enum variants | ||
| pub trait TransactionExt { | ||
| /// Returns true if this is a payment transaction | ||
| fn is_payment(&self) -> bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also wondering it we'd be better to simply have a function which exposes a transaction type enum defined in algokit_transact (I think we'd need to add).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so i still kept the transaction ext trai with is methods, they are useful for single type checks and simple conditionals, loosely mirroring the approach with wrapped transaction classes we used in utils py in relation to sender abstraction. But also added a TransactionType enum for cases when more comprehensive pattern matching is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured if we had transaction type we could remove all the is_{type} methods.
- app_call_method → app_call_method_call - app_create_method → app_create_method_call - app_update_method → app_update_method_call - app_delete_method → app_delete_method_call Addresses PR comments about naming consistency and explicitness. Updated test usage to match new method names. Refs: PR#229 comment IDs 2278470125, 2278475769, 2278475920, 2278476947
…tency - Add get_box_value_from_abi_type() returning ABIValue directly - Add get_box_values_from_abi_type() returning Vec<ABIValue> - Keep existing ABIMethod-based methods returning ABIReturn - Provides both simple direct decoding and rich context workflows - Matches TypeScript/Python API patterns while maintaining workflow integration Addresses PR comments about API consistency and providing both method types. Tests added to demonstrate the differences between approaches. Refs: PR#229 comment IDs 2278419350, 2278420074, 2278459006
- Rename 'base' field to 'common_params' in SendResult structs for consistency - Remove public parse_abi_return method, use static get_abi_return instead - Update base64 encoding comment to specify JSON responses over HTTP - Aligns with established codebase patterns (common_params used 74+ times) - Reduces public API surface while maintaining functionality Addresses PR comments about consistency and precision. Refs: PR#229 comment IDs 2278487146, 2278420725, 2278425272
…ganization - Move TransactionExt trait from standalone file to transactions/mod.rs - Co-locate transaction extension logic with Transaction type definition - Update imports to maintain public API compatibility - Remove transaction_ext.rs file (no longer needed) - All tests passing, maintains backward compatibility Improves code organization by grouping transaction-related functionality. Refs: PR#229 comment ID 2278400067
- Add asset_id() method as semantic alias for index field - Add convenience methods to flatten .params. access pattern: total(), decimals(), unit_name(), name() - Update tests to use ergonomic methods instead of nested field access - Maintains raw algod types while improving developer experience - Addresses test structure and naming consistency feedback Refs: PR#229 comment IDs 2278463115, 2278464299
- Make close_remainder_to field optional in AssetOptOutParams - Auto-resolve to asset creator when None (most common use case) - Maintain explicit address option with Some(address) - Update all usage and tests to use new optional pattern - Eliminates need for separate convenience methods - Cleaner API design as suggested in review Users can now pass None for automatic creator resolution or Some(address) for explicit control. Refs: PR#229 comment ID 2278439775
…ation
- Add TransactionType enum with variants: Payment, AssetTransfer, AssetCreate,
AssetFreeze, ApplicationCall, KeyRegistration
- Add transaction_type() method to TransactionExt trait
- Enables ergonomic pattern matching: match tx.transaction_type() { ... }
- Maintains backward compatibility with existing is_*() methods
- Zero-cost abstraction with comprehensive test coverage
- Addresses architectural feedback about unified transaction type approach
Users can now choose between individual boolean methods or
enum-based pattern matching for transaction type handling.
Refs: PR#229 comment ID 2278408184
- Remove backwards compatibility test for is_*() vs transaction_type() methods Both approaches were added in same dev branch, no need for compatibility testing - Remove convenience methods from algod Asset model added just for test ergonomics Use direct field access in tests instead of bloating generated API types - Embrace refined approaches rather than maintaining compatibility with interim code This cleanup eliminates 32 lines of unnecessary code while maintaining the same functionality. Generated API types should stay lean.
…onomic interface - Add AssetInformation struct with direct field access (asset.total vs asset.params.total) - Remove nested .params access patterns for better developer experience - Implement automatic conversion from algod_client::models::Asset - Update AssetManager.get_by_id() to return AssetInformation instead of raw Asset - Update all consuming code (sender.rs, tests) to use flattened structure - Add comprehensive unit tests for AssetInformation conversion - Export AssetInformation type from crate for public usage - Align with TypeScript/Python AlgoKit implementations for consistency Breaking change: AssetManager.get_by_id() now returns AssetInformation instead of algod_client::models::Asset, but provides better ergonomics. Addresses PR comment about folding away nested .params structure
| /// Extension trait providing accessor methods for Transaction enum variants | ||
| pub trait TransactionExt { | ||
| /// Returns true if this is a payment transaction | ||
| fn is_payment(&self) -> bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured if we had transaction type we could remove all the is_{type} methods.
Removes get_box_value_from_abi_method() and get_box_values_from_abi_method() methods that don't make architectural sense: - Box storage is independent of method calls - ABIMethod represents function calls, not data storage formats - Box data should be decoded by storage type (ABIType), not method signatures This addresses Neil's feedback that it doesn't make sense to pass an ABI method to functions reading box data. The TypeScript implementation confirms this approach - it only uses ABIType for box decoding, never ABIMethod. Maintains correct methods: - get_box_value_from_abi_type() ✓ (TypeScript-compatible) - get_abi_return() taking ABIMethod ✓ (for transaction returns) Fixes #229 review comment
Removes get_box_value_from_abi_method() and get_box_values_from_abi_method() methods that don't make architectural sense: - Box storage is independent of method calls - ABIMethod represents function calls, not data storage formats - Box data should be decoded by storage type (ABIType), not method signatures This addresses Neil's feedback that it doesn't make sense to pass an ABI method to functions reading box data. The TypeScript implementation confirms this approach - it only uses ABIType for box decoding, never ABIMethod. Maintains correct methods: - get_box_value_from_abi_type() ✓ (TypeScript-compatible) - get_abi_return() taking ABIMethod ✓ (for transaction returns) Fixes #229 review comment
c8d7ae1 to
a5c2ff2
Compare
- Remove mut from AssetOptOutParams parameter - Use conditional assignment with struct reconstruction instead of mutation - Addresses Neil's PR feedback to avoid unnecessary mutability
| /// Get the asset configuration transaction from the common transaction | ||
| pub fn asset_config_transaction(&self) -> Option<&AssetConfigTransactionFields> { | ||
| self.common_params.transaction.as_asset_create() | ||
| if let Transaction::AssetConfig(asset_config) = &self.common_params.transaction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neilcampbell ended up removing the enum and transaction ext trait in favor of idiomatic pattern matching
da2f57f to
5ae6826
Compare
…ce idiomatic Rust Removes abstraction layers that don't add value and encourages idiomatic Rust patterns: REMOVED: - TransactionExt trait (68 lines of abstraction) - TransactionType enum (26 lines) - All is_*() boolean methods (is_payment, is_asset_transfer, etc.) - All as_*() accessor methods except as_app_call() (the only one actually used) - transaction_type() method KEPT (Essential methods actually used in codebase): - Header accessors: sender(), fee(), first_valid_round(), last_valid_round(), note() - as_app_call() - the only accessor method actually used in production MIGRATION: - sender_results.rs: Updated to use matches!(tx, Transaction::Payment(_)) instead of tx.is_payment() - Tests: Demonstrate idiomatic pattern matching instead of abstraction layers BENEFITS: - 90% reduction in API surface area (from 18 methods to 6) - Zero runtime overhead (direct pattern matching vs trait dispatch) - Idiomatic Rust - follows ecosystem patterns like Option/Result - Matches TypeScript/Python approach of direct type checking - Encourages explicit, type-safe pattern matching
5ae6826 to
86f32a3
Compare
|
🎉 This PR is included in version 1.0.0-alpha.53 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.0.0-alpha.45 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Minimal versions of app manager; asset manager and full versions of creator and sender abstractions as prereqs for app client pr