-
Notifications
You must be signed in to change notification settings - Fork 11
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
conversion to base64 string #35
base: polkadot-v1.1.0
Are you sure you want to change the base?
Conversation
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.
👍
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.
Thanks @b-yap, just one question.
src/utils/std.rs
Outdated
impl <T: XdrCodec> StellarTypeToBase64String for T { | ||
fn as_base64_encoded_string(&self) -> String { | ||
let xdr = self.to_base64_xdr(); | ||
String::from_utf8(xdr.clone()).unwrap_or(format!("{:?}", xdr)) |
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.
Does the or
case ever happen? I think we can prove that the unwrap can never fail (something the compiler can't guarantee) because to_base64_xdr
will always return an ASCII string, which is always valid utf8.
That way we should be able to safely use unrwap
and we would not need to add the std::format
or alloc::format
dependency. Or is this bad practice?
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.
Does the or case ever happen?
True, it will not.
I have reverted std.rs file and use unwrap()
.
I do not think it is bad practice, as long as explained well.
Move implementation of
https://github.com/pendulum-chain/spacewalk/blob/7c7989875e95e1cfe3b0aeba9bb6af01d9e33e58/clients/stellar-relay-lib/src/connection/helper.rs#L39-L42
to this repo
Cleanup of pendulum-chain/spacewalk#545