Skip to content

Commit

Permalink
https://github.com/pendulum-chain/substrate-stellar-sdk/pull/35/files…
Browse files Browse the repository at this point in the history
…#r1801904523
  • Loading branch information
b-yap committed Oct 16, 2024
1 parent 10abda2 commit 52e366e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 0 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@ mod lib {
#[cfg(not(feature = "std"))]
pub use alloc::string::{FromUtf8Error, String, ToString};

#[cfg(not(feature = "std"))]
pub use alloc::format;

#[cfg(feature = "std")]
#[allow(unused_imports)]
pub use std::string::{FromUtf8Error, String, ToString};

#[cfg(feature = "std")]
#[allow(unused_imports)]
pub use std::format;
}

mod amount;
Expand Down
5 changes: 3 additions & 2 deletions src/utils/std.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::lib::{String, format};
use crate::lib::String;
use crate::XdrCodec;

/// A trait used to convert any Stellar specific type `T` as a String
Expand All @@ -20,6 +20,7 @@ pub trait StellarTypeToBase64String {
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))
// safe to use `unwrap`, since `to_base64_xdr()` will always return a valid vec of
String::from_utf8(xdr.clone()).unwrap()
}
}

0 comments on commit 52e366e

Please sign in to comment.