-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Add support for Asset Freeze transactions #167
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
base: main
Are you sure you want to change the base?
Conversation
- Implement AssetFreezeTransactionFields with asset_id, freeze_target, and frozen fields - Add AssetFreezeTransactionBuilder with derive_builder pattern support - Update Transaction enum to include AssetFreeze variant with proper serde serialization - Add FFI bindings for cross-language support (Python, TypeScript, Swift) - Update all transaction handling code to support the new transaction type - Add comprehensive test coverage including encoding/decoding, transaction IDs, fee calculation, and transaction grouping - Include test data generation for both freeze and unfreeze scenarios - Add example usage in Python and TypeScript test suites This enables freezing and unfreezing of asset holdings for specific accounts, allowing asset managers to control transfer permissions on a per-account basis.
c876e58
to
005e406
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 adds support for Asset Freeze transactions across the core library, FFI bindings, and language-specific SDKs.
- Introduce
AssetFreezeTransactionFields
andAssetFreezeTransactionBuilder
in Rust core - Extend
Transaction
enum, serialization, FFI, fee calculation, and ID logic to cover asset freeze/unfreeze - Add comprehensive tests and examples in TypeScript, Python, and Rust
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/typescript/algokit_transact/tests/asset_freeze.test.ts | Add TS tests for freeze/unfreeze encoding, ID, fee |
packages/python/algokit_transact/tests/test_asset_freeze.py | Add Python tests for asset freeze transactions |
crates/algokit_transact_ffi/src/lib.rs | Expose AssetFreezeTransactionFields via FFI |
crates/algokit_transact/src/transactions/mod.rs | Register AssetFreeze variant in the core Transaction enum |
crates/algokit_transact/src/transactions/asset_freeze.rs | Define the Rust AssetFreezeTransactionFields struct |
crates/algokit_transact/src/tests.rs | Add end-to-end Rust tests for freeze/unfreeze flows |
crates/algokit_transact/src/test_utils/mod.rs | Extend test utilities to generate freeze/unfreeze data |
crates/algokit_transact/src/lib.rs | Re-export freeze builder/fields in top-level API |
Comments suppressed due to low confidence (2)
packages/python/algokit_transact/tests/test_asset_freeze.py:110
- It could be valuable to also verify that the decoded transaction’s
freeze_target
matches the original address (e.g.,assert decoded.asset_freeze.freeze_target.address == target_account.address
).
assert get_encoded_transaction_type(encoded) == TransactionType.ASSET_FREEZE
crates/algokit_transact/src/transactions/asset_freeze.rs:25
asset_id
andfreeze_target
are required fields for this transaction. Consider adding builder validation (e.g., via#[builder(validator(...))]
) to ensureasset_id > 0
andfreeze_target
is not a zero address.
pub struct AssetFreezeTransactionFields {
@@ -0,0 +1,128 @@ | |||
import { expect, test, describe } from "bun:test"; |
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.
[nitpick] The test suite is imported from "bun:test", which may conflict with the project's standard runner (e.g., Jest or Vitest). Consider aligning the import with the rest of the repository’s test framework for consistency.
Copilot uses AI. Check for mistakes.
)); | ||
} | ||
|
||
let data = tx.clone().asset_freeze.unwrap(); |
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.
Cloning the entire Transaction
just to extract asset_freeze
can be expensive. Instead, pattern-match on tx.asset_freeze
or take()
the field to avoid a full struct clone.
let data = tx.clone().asset_freeze.unwrap(); | |
let data = tx.asset_freeze.unwrap(); |
Copilot uses AI. Check for mistakes.
This enables freezing and unfreezing of asset holdings for specific accounts, allowing asset managers to control transfer permissions on a per-account basis.