Skip to content
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

Added Swap Watcher Service #506

Open
wants to merge 22 commits into
base: refactoring-bloc
Choose a base branch
from

Conversation

i5hi
Copy link
Collaborator

@i5hi i5hi commented Mar 5, 2025

  • Refactor repository and services to ensure domain does not depend on data layer
  • Add swap watcher & swap processing
  • Add basic swap interaction with wallets
  • Implement Fees & Limits logic

@i5hi i5hi added the enhancement New feature or request label Mar 5, 2025
@i5hi i5hi self-assigned this Mar 5, 2025
Copy link
Contributor

@kumulynja kumulynja left a comment

Choose a reason for hiding this comment

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

I think the main things to change are combining storage and api again to just a boltz_data_source class, or at least inject the storage one in the api one, so that creating a swap contains both creating the swap with the api as persisting it, and returning one BoltzSwapModel type instead of library types.

Then the second main thing is also using the model in the boltz SwapStatusStream processing so the types of the stream the datasource exposes also is BoltzSwapModel and not a library type, keeping all dependencies on boltz-dart abstracted in the datasource.

Future<List<SwapModel>> getAll();
Future<void> delete(String swapId);
// Secure Storage
Future<void> storeBtcLnSwap(BtcLnSwap swap);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to make every concrete Boltz Swap type (BtcLnSwap, LbtcLnSwap and ChainSwap) have a common base type? If so, it would not be required to have a separate method that does exactly the same thing for every type. This will reduce the amount of code needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its possible to make a common base type for the *LnSwap but ChainSwap has a different interface. It will require some additional code in the library in dart beyond what is generated automatically by flutter_rust_bridge.

Although, I think the explicit methods are clear and safe ? We won't need to check if what we got back is a Btc or Lbtc swap because the method will always return exactly the one the caller wants.

@i5hi
Copy link
Collaborator Author

i5hi commented Mar 5, 2025

@kumulynja This is ready for final review and merge.

@i5hi
Copy link
Collaborator Author

i5hi commented Mar 6, 2025

I think the main things to change are combining storage and api again to just a boltz_data_source class, or at least inject the storage one in the api one, so that creating a swap contains both creating the swap with the api as persisting it, and returning one BoltzSwapModel type instead of library types.

Then the second main thing is also using the model in the boltz SwapStatusStream processing so the types of the stream the datasource exposes also is BoltzSwapModel and not a library type, keeping all dependencies on boltz-dart abstracted in the datasource.

Injected storage into the main datasource, its now just called BoltzDataSource. Also storing the swaps at the time of creation at the datasource and always returning SwapModel or other basic types.

Mapped SwapStreamStatus to (String, String) and now boltz-dart types are ONLY used in the datasource.

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

Successfully merging this pull request may close these issues.

2 participants