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

refactor: restructure balance #415

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

reez
Copy link
Collaborator

@reez reez commented Nov 15, 2023

Description

Refactor Balance to Use Dictionary and Struct Patterns

Notes to the reviewers

Previously in 0.30.0 Balance was a dictionary. Currently in the 1.0 migration Balance is an interface.

The main motivation for this PR came via testing our bdk-swift 1.0.0 bindings locally in an iOS app where Balance was an interface; it made me want Balance to go back to being a dictionary instead of an interface if possible.

Example: In bdk-swift Balance is more ergonomic as a concrete type in my opinion (a struct instead of a protocol); an example where that is nice is if Balance is a struct it can be instantiated and mocked out, as opposed to if Balance is a protocol then a MyBalance struct needs to be created that conforms to the protocol Balance.

Key Changes:

  • In UDL, Balance is now a dictionary instead of an interface.
  • In lib.rs, Balance is now a struct instead of an impl

Tests across all platforms have been updated to reflect this refactor.

Changelog notice

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@reez reez marked this pull request as ready for review November 15, 2023 22:24
@reez reez requested a review from thunderbiscuit November 16, 2023 15:01
Copy link
Member

@notmandatory notmandatory left a comment

Choose a reason for hiding this comment

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

ACK b66524b

Makes sense for bindings to make this into a dictionary. Be aware that the "trusted" balances should be going away based on conversation in bitcoindevkit/bdk#797, but can do that in a different PR once the change is made to BDK.

@reez
Copy link
Collaborator Author

reez commented Dec 6, 2023

Rebased on master

Copy link
Member

@thunderbiscuit thunderbiscuit left a comment

Choose a reason for hiding this comment

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

ACK 05ce7da.

@thunderbiscuit thunderbiscuit merged commit 05ce7da into bitcoindevkit:master Dec 6, 2023
17 checks passed
@reez reez deleted the 414+balance branch December 6, 2023 23:23
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.

3 participants