feat(swap): add Cardano and Zcash support for Near Intents#161
Conversation
Add Cardano (ADA) and Zcash (ZEC) as source and destination assets in Near Intents swap provider. Includes transaction param models, transaction building logic, and comprehensive tests.
There was a problem hiding this comment.
Pull request overview
This PR adds support for Cardano (ADA) and Zcash (ZEC) as source and destination assets in the Near Intents swap provider, expanding the supported UTXO-based blockchains beyond Bitcoin.
Key Changes:
- Introduced
UtxoChainTransactionParamsbase class to handle shared transaction parameters for UTXO-based chains (Bitcoin, Cardano, Zcash) - Added Cardano and Zcash transaction building logic following the same pattern as Bitcoin
- Comprehensive test coverage for both new chains with proper validation of transaction parameters
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/api/swap/models.py | Added UtxoChainTransactionParams base class and specific CardanoTransactionParams and ZcashTransactionParams classes; updated TransactionParams model to include cardano and zcash fields |
| app/api/swap/providers/near_intents/transformations.py | Imported new transaction param models and added Cardano/Zcash handling in _build_transaction_params function; updated documentation to reflect new supported chains |
| app/api/swap/providers/near_intents/utils.py | Added fee estimation handling for Cardano and Zcash UTXO chains (returns None, similar to Bitcoin) |
| app/api/swap/providers/near_intents/test_client.py | Added comprehensive tests for Cardano and Zcash swap routes; refactored unsupported chain test to use Filecoin instead of Zcash |
| app/api/swap/providers/near_intents/mocks.py | Added ADA_TOKEN_INFO and FIL_TOKEN_INFO mock data for testing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class UtxoChainTransactionParams(SwapBaseModel): | ||
| chain: ChainSpec | ||
| to: str | ||
| value: str | ||
| refund_to: str | ||
|
|
There was a problem hiding this comment.
Consider adding a docstring to the UtxoChainTransactionParams base class to document that it serves as a shared parameter model for UTXO-based chains (Bitcoin, Cardano, Zcash) that all share the same transaction structure. This would improve code documentation and help future developers understand the design pattern.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add Cardano (ADA) and Zcash (ZEC) as source and destination assets in Near Intents swap provider. Includes transaction param models, transaction building logic, and comprehensive tests.