-
Notifications
You must be signed in to change notification settings - Fork 116
Add composable wallet trait system #1581
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
497aa6d to
85ffb8b
Compare
crates/cdk/src/wallet/traits.rs
Outdated
|
|
||
| #[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))] | ||
| #[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] | ||
| impl WalletMintInfo for Wallet { |
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.
Do we see a use case where we would want multiple traits to implement only part of the api? I don't think I see one and one trait would be simpler.
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.
Is it any better at 1a2fd1f?
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.
i don't see how this change addresses the comment of 1 wallet trait vs the multiple it still has multiple. To be clear I not strongly against having multiple traits if there is a reason for it, just one trait would be simpler but if others see a use case for the multiple I'm okay with that.
1a2fd1f to
b535f81
Compare
b535f81 to
84528dd
Compare
3dbcb17 to
60280ad
Compare
Add a new `Wallet` trait in cdk-common that provides a comprehensive interface for all wallet operations with associated types. This enables trait-based polymorphism for different wallet implementations, better FFI support, and cleaner separation between interface and implementation. The `mint_quote` method now accepts a `PaymentMethod` parameter and routes to Bolt11, Bolt12, or Custom payment backends — matching the existing `melt_quote` pattern. Key changes: - Define `Wallet` trait in cdk-common with associated types for Amount, Proofs, MintQuote, MeltQuote, Token, PaymentMethod, etc. - Implement the trait for the concrete `Wallet` struct in cdk - Route `mint_quote` by PaymentMethod (Bolt11/Bolt12/Custom) - Add wallet_trait.rs to cdk-ffi for FFI support - Update CLI, multi-mint wallet, examples, and integration tests - Refactor balance, keyset, and issue modules to use the trait
60280ad to
ee94ebb
Compare
Description
Introduce a modular trait system for wallet implementations that enables flexible composition of wallet capabilities. This allows different wallet implementations to share a common interface while supporting selective trait implementation.
The trait hierarchy consists of:
Implements all traits for both cdk::Wallet and cdk-ffi::Wallet, enabling generic code that works with any wallet implementation.
Notes to the reviewers
Suggested CHANGELOG Updates
CHANGED
ADDED
REMOVED
FIXED
Checklist
just final-checkbefore committing