This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Conversation
Replace custom transaction group management with algosdk's `AtomicTransactionComposer` (ATC) to improve reliability and maintainability. Changes: `SwapComposer` Refactoring - Delegate transaction management to ATC instead of reimplementing group logic - Add public `buildGroup()` method with JSDoc documentation - Add auto-add swap transactions logic to `submit()` and `execute()` for backward compatibility - Remove manual group ID assignment, signing coordination, and status management - Simplify `sign()`, `submit()`, and `execute()` to delegate to ATC methods Internal Method Updates - `createDeflexSigner()`: New method that wraps Deflex pre-signed transaction logic in `TransactionSigner` function - `defaultSigner`: New wrapper for configured signer that filters out null values (ARC-1 compliance) - `processSwapTransactions()`: Refactored to return `TransactionWithSigner[]` instead of `SwapTransaction[]` - `processRequiredAppOptIns()`: Refactored to return `TransactionWithSigner[]` instead of `SwapTransaction[]` Type Changes - Import `TransactionWithSigner` and `ABIResult` types from algosdk - Deprecate `SwapTransaction` type in favor of `algosdk.TransactionWithSigner` - Add `methodResults` to `execute()` return type for ABI method call support Test Updates - Refactor tests to spy on ATC methods instead of testing internal implementation - Focus on testing SwapComposer's behavior (delegation, auto-add, parameter passing) - Add error handling tests for invalid signature structures - Remove `waitForConfirmation` mock and unused `algodClient` methods - Add helper for creating valid signed transaction blobs - Improve test coverage from 91.89% to 94.59% There are no breaking changes to the public API. All changes are internal or additive. Benefits: - Reduced code complexity and maintenance burden - Leverage battle-tested ATC implementation - Better support for future features (ABI method calls, etc.) - Improved test reliability and execution speed
Add support for including ABI method calls in swap transaction groups by exposing AtomicTransactionComposer's `addMethodCall` functionality. Changes: SwapComposer API - Add `addMethodCall()` method as pass-through to ATC's `addMethodCall()` - Returns `this` for method chaining consistency with other add methods - Includes JSDoc documentation Type Definitions - Add `MethodCall` interface copied from ATC's inline parameter definition - Includes all 21 parameters from ATC's method call configuration - Update imports in `types.ts` to use named imports from algosdk for better tree-shaking Benefits: - Enables users to compose swap transactions with ABI method calls - Maintains consistency with ATC's API surface - Prepares for advanced use cases like flash loans, multi-step DeFi operations, etc.
Update code examples to reflect correct API usage and provide more practical output examples. Changes: - Add `signer` parameter to `newSwap()` examples for accuracy - Fix `execute()` call to remove incorrect `signer` parameter - Enhance `buildGroup()` example to show practical output (group ID, length, status)
Update `addMethodCall()` to follow the two-argument pattern established by `addTransaction()`, providing flexibility in how signers are specified. Changes: - Add optional `signer` parameter to `addMethodCall()` that defaults to `this.defaultSigner` - Make `signer` property optional in `MethodCall` interface - Implement fallback logic: `methodCall.signer` → parameter signer → constructor signer - Add JSDoc documentation explaining the signer resolution order - Keep `sender` required to avoid implicit assumptions about transaction origin Benefits: - Consistent API pattern across `addTransaction()` and `addMethodCall()` - Flexibility to specify signer inline, as parameter, or use default - Explicit about sender while providing sensible signer defaults
Update README to showcase the new ABI method call functionality in SwapComposer. Changes: - Add `addMethodCall()` to Advanced Transaction Composition example - Show how to define and use a MethodCall in the composition flow - Update SwapComposer API reference table to include `addMethodCall()` and `buildGroup()` - Add optional `signer` parameter documentation for `addTransaction()` - Fix `getStatus()` return type
Update the `execute()` method's return type to accurately reflect the inline type
definition that includes `methodResults`.
Changes:
- Replace generic `PendingTransactionResponse` with actual return type
- Show `{ confirmedRound: bigint, txIds: string[], methodResults: ABIResult[] }` inline
- Aligns documentation with the ATC integration changes
Add comprehensive tests for the three-tier signer resolution in `addMethodCall()`. Tests cover: - Using `methodCall.signer` when provided (highest priority) - Using parameter `signer` when `methodCall.signer` is undefined - Using constructor's `defaultSigner` when neither is provided (lowest priority) - Method chaining behavior All 112 tests passing.
Reorder methods so `addMethodCall()` follows `addTransaction()` and precedes `addSwapTransactions()`, grouping the "add" methods together in a logical sequence.
github-actions bot
added a commit
that referenced
this pull request
Nov 4, 2025
# [1.2.0](v1.1.0...v1.2.0) (2025-11-04) ### Features * refactor SwapComposer to use AtomicTransactionComposer internally ([#17](#17)) ([cebb16c](cebb16c))
Contributor
|
🎉 This PR is included in version 1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor SwapComposer to use Algorand SDK's AtomicTransactionComposer (ATC) internally instead of reimplementing transaction group management. This architectural change improves maintainability, reliability, and adds support for ABI method calls in swap transaction groups.
Changes
SwapComposer Refactoring
sign(),submit(), andexecute()to delegate to ATC methodssubmit()andexecute()for backward compatibilityNew Features
buildGroup(): Expose ATC's buildGroup method with comprehensive JSDocaddMethodCall(methodCall, signer?): Enable ABI method calls in swap groupsaddTransaction()MethodCallinterface: Type definition for ABI method call parametersEnhanced Features
addTransaction(transaction, signer?): Added optional signer parameter with fallback to constructor signerexecute()return type: AddedmethodResults: ABIResult[]for ABI method call supportType Changes
TransactionWithSignerandABIResultfrom algosdkSwapTransactiontype (still exported, useTransactionWithSignerinstead)MethodCallinterface based on ATC's inline definition withsignermade optional to support fallback behaviorTest Updates
addMethodCall()signer fallback logicwaitForConfirmationmock and unusedalgodClientmethodsDocumentation
addMethodCall()andbuildGroup()to API reference tableexecute()return type documentation to show inline type withmethodResultsBreaking Changes
None - All changes are internal, additive, or backward compatible.
Compatibility Details:
addTransaction()- Optionalsignerparameter added (backward compatible)execute()- AddedmethodResultsfield to return object (additive, backward compatible)SwapTransaction- Deprecated but still exported (not removed)Benefits
Testing