Remove use of payjoin::Url and url::Url in public Api#1057
Remove use of payjoin::Url and url::Url in public Api#1057DanGould merged 2 commits intopayjoin:masterfrom
Conversation
72d450b to
c4b9a96
Compare
Pull Request Test Coverage Report for Build 17654923783Details
💛 - Coveralls |
a8892e0 to
a4a85f1
Compare
739cc4b to
b53dc45
Compare
There was a problem hiding this comment.
Glad to see this started. I have a feeling this overshot the mark by a bit in two main ways
- Why is
impl IntoUrlremoved from the public API for &str when Urls are expected?payjoin::IntoUrlis our way to have a typesafe URL passed without exposing the explicit dependency onurl::Url, letting us get rid of the dependency onurlin the future. However, we still want a strong Url type contract in the API andIntoUrlgets us there in function definitions. - Why was
url::Urlremoved from payjoin-cli?url::Urlin payjoin-cli types still seems appropriate because it minimizes this change for review and allowsurl::Urlto still be removed from thepayjoininterface. It lets payjoin-cli continue to have validation on config where it may not otherwise and simply allows the core payjoin crate to go without for the dependency sticklers.
And undershot in one main way: it didn't remove url::Url from the public IntoUrl interface by removing the following lines from into_url.rs as described here
- impl IntoUrl for &Url {}
- impl IntoUrl for Url {}|
Thanks for the review, I perhaps misunderstood the exact issue that we really just want to disallow accepting a Url in IntoUrl and other methods instead of trying to transition over to using a string reference instead As a result it was my intention to try and keep some type arg consistency on the external crates, but I will walk back some of these changes now that I know the scope is a little more narrow. |
|
Also for ergonomics because then you can pass both |
1d66a52 to
3220474
Compare
There was a problem hiding this comment.
Better.
A few things remain:
- Why are we
expecting valid urls for unparsed inputs. That sounds like a recipe for disaster. I know you know better than that and these instances are just a goofs but c'mon man a panic is srs bizns. This has gotta be fixed.
edit: this was a bit harsh I make booboos like this sometimes too. Hope you don't take it the wrong way, Ben.
2. Lots of to_string where as_str() will do. Indeed we're not auditing the enforcement but I think we can at least use best practice all over the place here to demonstrate minimized mem use.
3. Internal APIs can and should use Url to take advantage of the type's strong validation since we're not pulling that dependency out yet.
| let receiver: Arc<corepc_node::Client> = Arc::new(receiver); | ||
| let receiver_clone = receiver.clone(); | ||
| let ohttp_relay = services.ohttp_relay_url(); | ||
| let ohttp_relay = services.ohttp_relay_url().to_string(); |
There was a problem hiding this comment.
This actually probably should remain a string type with the ownership within the receiver loop
65ab3db to
31b3403
Compare
6c39e5e to
04cff71
Compare
|
Heads up @benalleng there is a conflict on this branch after #1046 |
04cff71 to
48bcda4
Compare
DanGould
left a comment
There was a problem hiding this comment.
Needs a slight signature change now that crate::uri is pub and visibility lets us internalize some functions to allow them to take validated url::Url and not have to return Results
e4f30aa to
f301b1e
Compare
f301b1e to
8872c34
Compare
8872c34 to
aa7a7c3
Compare
This commit removes the Url from the public Api where it is an arg in public api methods and also as an impl in the IntoUrl interface so that it is not accepted where IntoUrl is used. This commit does not remove Url internally from the payjoin crate or remove the use of Url in any external crates, it simply transitions the type to a `&str` or `String` when passing into payjoin methods.
This is a minor commit in a simplification I found could be made in some send tests using existing consts
aa7a7c3 to
c46687f
Compare
This PR aims to remove the use of
Urlin the public API args and acceptingUrlof&Urlin ourIntoUrlinterface.ChatGpt was used in some error correction along the way and type conversions for strings to urls.
closes #513
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.