Skip to content

Sending ABI methods with composer #221

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 1 commit into from
Aug 12, 2025
Merged

Sending ABI methods with composer #221

merged 1 commit into from
Aug 12, 2025

Conversation

PatrickDinh
Copy link
Collaborator

Fixes #

Proposed Changes

@@ -152,3 +152,60 @@ pub struct AssetDestroyParams {
/// ID of the existing asset to be destroyed.
pub asset_id: u64,
}

pub fn build_asset_create(params: &AssetCreateParams, header: TransactionHeader) -> Transaction {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these methods were refactored out of composer.rs

@PatrickDinh PatrickDinh marked this pull request as ready for review August 7, 2025 11:33
@Copilot Copilot AI review requested due to automatic review settings August 7, 2025 11:33
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 implements the ability to send ABI methods using the composer, introducing comprehensive support for application method calls alongside existing raw transaction functionality.

  • Adds new ApplicationMethodCallParams and related parameter structures for ABI method calls
  • Implements ABI method argument handling including payments, application calls, transactions, and references
  • Extends the composer with add_application_method_call functionality to complement existing raw transaction methods

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
inner_fee_coverage.rs Refactors test file to use new ApplicationRawCallParams instead of deprecated ApplicationCallParams
asset_transfer.rs Minor import reorganization moving asset-related imports to main utils module
application_call.rs Major addition of comprehensive ABI method call tests and new parameter structures
contract.py Adds new sandbox contract with various ABI methods for testing complex scenarios
Sandbox.arc56.json Contract specification file defining the sandbox contract's ABI interface
payment.rs Adds utility functions build_payment and build_account_close for transaction construction
mod.rs Updates module exports to include new transaction parameter types and removes deprecated ones
key_registration.rs Adds builder functions for different types of key registration transactions

@@ -26,3 +26,22 @@ pub struct AccountCloseParams {
/// The address to receive the remaining funds.
pub close_remainder_to: Address,
}

Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

The new build_payment function lacks documentation. Add a doc comment explaining its purpose, parameters, and return value.

Suggested change
/// Builds a payment transaction that sends ALGO from the sender to the specified receiver.
///
/// # Parameters
/// - `params`: The parameters specifying the receiver and amount to send.
/// - `header`: The transaction header, including sender and other common fields.
///
/// # Returns
/// A `Transaction` representing the payment transaction.

Copilot uses AI. Check for mistakes.

close_remainder_to: None,
})
}

Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

The new build_account_close function lacks documentation. Add a doc comment explaining its purpose, parameters, and return value.

Suggested change
/// Builds a payment transaction that closes an account by transferring all remaining funds
/// to the specified `close_remainder_to` address.
///
/// # Parameters
/// - `params`: The parameters specifying the recipient of the remaining funds.
/// - `header`: The transaction header, including the sender's address.
///
/// # Returns
/// A `Transaction` representing the account close operation.

Copilot uses AI. Check for mistakes.

@@ -21,3 +23,51 @@ pub struct OfflineKeyRegistrationParams {
pub struct NonParticipationKeyRegistrationParams {
pub common_params: CommonParams,
}

Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

The new build_online_key_registration function lacks documentation. Add a doc comment explaining its purpose, parameters, and return value.

Suggested change
/// Builds an online key registration transaction.
///
/// # Parameters
/// - `params`: Reference to [`OnlineKeyRegistrationParams`] containing the key registration details,
/// such as vote key, selection key, voting period, key dilution, and optional state proof key.
/// - `header`: The [`TransactionHeader`] to use for the transaction.
///
/// # Returns
/// A [`Transaction`] representing an online key registration with the provided parameters.

Copilot uses AI. Check for mistakes.

non_participation: None,
})
}

Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

The new build_offline_key_registration function lacks documentation. Add a doc comment explaining its purpose, parameters, and return value.

Suggested change
/// Builds an offline key registration transaction.
///
/// # Parameters
/// - `params`: The parameters for the offline key registration, including common transaction fields and optional non-participation flag.
/// - `header`: The transaction header containing metadata such as sender, fee, and validity period.
///
/// # Returns
/// A `Transaction` representing the offline key registration.

Copilot uses AI. Check for mistakes.

non_participation: params.non_participation,
})
}

Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

The new build_non_participation_key_registration function lacks documentation. Add a doc comment explaining its purpose, parameters, and return value.

Suggested change
/// Builds a key registration transaction that marks the account as non-participating.
///
/// # Parameters
/// - `_params`: Reference to `NonParticipationKeyRegistrationParams` containing common transaction parameters.
/// - `header`: The transaction header to use for the transaction.
///
/// # Returns
/// A `Transaction` representing a non-participation key registration.

Copilot uses AI. Check for mistakes.

@PatrickDinh PatrickDinh changed the title DRAFT - sending ABI methods with composer Sending ABI methods with composer Aug 7, 2025
})
}

pub fn build_asset_reconfigure(
Copy link
Collaborator

Choose a reason for hiding this comment

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

was there a reason we initially defined this as reconfigure instead of configure? We don't have term reconfigure on utils py or ts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for the utils layer, we wanted to add some abstraction on top of asset configure, therefore, we have build_asset_create, build_asset_reconfigure, and build_asset_destroy. The different is small, for example, the create method doesn't need asset ID because it's always 0.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In utils-ts/py we call it asset_config. Based on the previous decision to align to utils-ts/py naming wherever possible, we should rename this as part of the stabilisation.

@joe-p joe-p self-requested a review August 8, 2025 18:24
Copy link
Collaborator

@joe-p joe-p left a comment

Choose a reason for hiding this comment

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

Minor feedback RE unwrap and unreachable, but otherwise LGTM

TransactionPlaceholder,
}

mod sealed {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Having a short comment describing why we have this sealed module would be useful. This pattern was new to me and other readers of the might also not be familiar with the purpose

ABIMethodArgType::Value(abi_type) => abi_type.clone(),
// Reference and transaction types encoded as uint8 indexes
// unwrap() is used because 8 is a valid BitSize
ABIMethodArgType::Reference(_) => ABIType::Uint(BitSize::new(8).unwrap()),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's generally preferable to use expect, with the arg being a "should" statement describing the invariant

Suggested change
ABIMethodArgType::Reference(_) => ABIType::Uint(BitSize::new(8).unwrap()),
ABIMethodArgType::Reference(_) => ABIType::Uint(BitSize::new(8).expect("8 should always be a valid BitSize")),

// Reference and transaction types encoded as uint8 indexes
// unwrap() is used because 8 is a valid BitSize
ABIMethodArgType::Reference(_) => ABIType::Uint(BitSize::new(8).unwrap()),
ABIMethodArgType::Transaction(_) => unreachable!(), // filtered out above
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it'd be preferable to use filter_map and return None for this branch so we can avoid the uncreachable!

Ok(ABIValue::Uint(BigUint::from(foreign_index)))
}
ProcessedAppMethodCallArg::ABIValue(value) => Ok(value.clone()),
ProcessedAppMethodCallArg::TransactionPlaceholder => unreachable!(), // filtered out above
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, I think filter_map is preferable

@PatrickDinh PatrickDinh merged commit e414cbc into main Aug 12, 2025
16 checks passed
@PatrickDinh PatrickDinh deleted the feat/app-client branch August 12, 2025 01:12
@engineering-ci
Copy link
Contributor

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

The release is available on:

Your semantic-release bot 📦🚀

@engineering-ci
Copy link
Contributor

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

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.

4 participants