Skip to content

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

Merged
merged 22 commits into from
Jul 15, 2025

Conversation

lempira
Copy link
Collaborator

@lempira lempira commented Jun 22, 2025

  • 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.

@lempira lempira force-pushed the feat/add-asset-freeze-txn branch from c876e58 to 005e406 Compare June 22, 2025 01:16
@lempira lempira marked this pull request as ready for review June 22, 2025 01:18
@Copilot Copilot AI review requested due to automatic review settings June 22, 2025 01:18
Copy link
Contributor

@Copilot 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 PR adds support for Asset Freeze transactions across the core library, FFI bindings, and language-specific SDKs.

  • Introduce AssetFreezeTransactionFields and AssetFreezeTransactionBuilder 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 and freeze_target are required fields for this transaction. Consider adding builder validation (e.g., via #[builder(validator(...))]) to ensure asset_id > 0 and freeze_target is not a zero address.
pub struct AssetFreezeTransactionFields {

@lempira lempira marked this pull request as draft June 22, 2025 01:27
@lempira lempira force-pushed the feat/add-asset-freeze-txn branch from 005e406 to 6225e27 Compare July 1, 2025 23:40
@lempira lempira marked this pull request as ready for review July 2, 2025 22:26
@lempira lempira force-pushed the feat/add-asset-freeze-txn branch from 87f5640 to 41a54f4 Compare July 3, 2025 02:43
@@ -156,6 +158,115 @@ impl TransactionMother {
.receiver(AddressMother::neil())
.to_owned()
}

pub fn asset_freeze() -> AssetFreezeTransactionBuilder {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You should move the builder methods for asset freeze to another file, following the pattern of app call and asset config.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you referring to the testing builder or the regular builder? The AssetFreezeTransactionBuilder lives in the asset_freeze.rs like the others.

@lempira lempira force-pushed the feat/add-asset-freeze-txn branch from fb8f3d4 to 51abbc2 Compare July 9, 2025 23:11
@lempira lempira requested a review from PatrickDinh July 10, 2025 03:01
@lempira lempira force-pushed the feat/add-asset-freeze-txn branch from e441e12 to c4b06fd Compare July 11, 2025 02:00
lempira and others added 15 commits July 11, 2025 13:16

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas
- 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.

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas
- Add asset freeze transaction support across Rust, Python, and TypeScript packages
- Update test utilities and test cases for asset freeze functionality
- Implement FFI bindings for asset freeze transactions

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas
wip

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas
PatrickDinh and others added 4 commits July 11, 2025 13:16
wip

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas
@lempira lempira force-pushed the feat/add-asset-freeze-txn branch from 415dd4f to 7d901d0 Compare July 11, 2025 17:17
@lempira lempira requested a review from PatrickDinh July 14, 2025 11:43

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas

Verified

This commit was signed with the committer’s verified signature.
lempira David Rojas
Copy link
Collaborator

@PatrickDinh PatrickDinh left a comment

Choose a reason for hiding this comment

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

LGTM

@lempira lempira merged commit 57377be into main Jul 15, 2025
16 checks passed
@lempira lempira deleted the feat/add-asset-freeze-txn branch July 15, 2025 00:39
@engineering-ci
Copy link
Contributor

🎉 This PR is included in version 1.0.0-alpha.35 🎉

The release is available on:

Your semantic-release bot 📦🚀

@engineering-ci
Copy link
Contributor

🎉 This PR is included in version 1.0.0-alpha.30 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants