feat: expose Display trait on Amount and Psbt types#1045
Conversation
480f6f1 to
1fd3084
Compare
|
Nice small addition, and this seems consistent with the Display exports already used for types like FeeRate, Script, Address, and Transaction. One small question: should this PR add a focused test for the new binding-facing Display behavior? Since this exposes Display through UniFFI, it would be useful to assert that Amount and Psbt stringify as expected, especially because the PR checklist marks tests as added but the diff only changes bitcoin.rs. |
|
Hey @j-kon , I should have included tests with the initial commit. I've pushed test_amount_display and test_psbt_display to cover the new Display behavior for both types. Regarding the changelog label — I have changelog: added in the PR body but it seems the label itself needs to be applied by someone with triage access. Could you add it? Thanks for the review! |
Thanks for adding the tests, that addresses my review comment. I don’t think I have triage access to apply labels on this repo, so I can’t add the |
ItoroD
left a comment
There was a problem hiding this comment.
Thanks for adding this. LGTM. Just a few comments commit message for the test should start with
test: add ....
| #[uniffi::export(Display)] | ||
| pub struct Amount(pub(crate) BdkAmount); | ||
|
|
||
| impl Display for Amount { |
There was a problem hiding this comment.
Just a nit. Usually we place the display Impl at the bottom of the type implementation. i.e after all implementations of the particular type.
| #[uniffi::export(Display)] | ||
| pub struct Psbt(pub(crate) Mutex<BdkPsbt>); | ||
|
|
||
| impl Display for Psbt { |
c793a9a to
458ca59
Compare
|
Hi @ItoroD! I have made all changes you mentioned to the PR. Kindly review it again. |
ItoroD
left a comment
There was a problem hiding this comment.
On second thought I am thinking we might not need the tests. As in the past we do not typically write tests explicitly for display. This will mean we will have lots of solely display tests for various types which I do not think its necessary. I will just leave this comment here to see what other reviews think.
I am happy to approve one the import change is made.
|
|
||
| #[test] | ||
| fn test_amount_display() { | ||
| let amount = crate::bitcoin::Amount::from_sat(100_000_000); |
There was a problem hiding this comment.
Here, maybe we can use the import at the top of the file like the others. So no need to use the fully qualified import here.
thunderbiscuit
left a comment
There was a problem hiding this comment.
If you can:
- Remove the test
- Rebase on master
I think this one is ready to go.
| ); | ||
| } | ||
|
|
||
| #[test] |
There was a problem hiding this comment.
I agree with @ItoroD; we do not need to add tests for the Display trait.
There was a problem hiding this comment.
@thunderbiscuit Agree with you, have made the required changes.
458ca59 to
342c716
Compare
|
@ItoroD and @thunderbiscuit Hi! I have made the required changes requested. Thanks! |
|
I apologize @shivv23 but I didn't notice your commits were not PGP signed. This is a requirement of the BDK Org, so you'll have to sign that commit before I can merge. Otherwise this looks good! (also keep an eye out because if I merge anything in between you'll also have to rebase). |
746203e to
ea5036d
Compare
|
Hi @thunderbiscuit! All feedback addressed (tests removed, Display placement moved to bottom of type impls, rebased on master). Commit is now GPG-signed and verified. Please take another look. |
Signed-off-by: shivv23 <shivamkumar0423@gmail.com>
ea5036d to
a62a58b
Compare
Description
Add #[uniffi::export(Display)] and implement the Display trait on the Amount and Psbt types, exposing them to the FFI bindings (Kotlin, Swift, Python).
Notes to the reviewers
This follows the same pattern used by other types in the codebase (FeeRate, Script, Address, Transaction, WalletEvent, etc.) that already expose Display to bindings. Part of issue #1020.
Documentation
Changelog
changelog: none
Checklists
All Submissions:
New Features: