Skip to content

Commit

Permalink
feat(iota-sdk): accept impl Into<String> instead of String (#2205)
Browse files Browse the repository at this point in the history
* feat(iota-sdk): accept impl Into<String> instead of String

* Clean example

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
Thoralf-M and thibault-martinez authored Sep 3, 2024
1 parent 747ccb1 commit c0cc650
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions crates/iota-sdk/examples/coin_read_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async fn main() -> Result<(), anyhow::Error> {
// Return the coin metadata for the Coin<IOTA>
let coin_metadata = client
.coin_read_api()
.get_coin_metadata("0x2::iota::IOTA".to_string())
.get_coin_metadata("0x2::iota::IOTA")
.await?;

println!(" *** Coin Metadata *** ");
Expand All @@ -106,7 +106,7 @@ async fn main() -> Result<(), anyhow::Error> {
// Total Supply
let total_supply = client
.coin_read_api()
.get_total_supply("0x2::iota::IOTA".to_string())
.get_total_supply("0x2::iota::IOTA")
.await?;
println!(" *** Total Supply *** ");
println!("{:?}", total_supply);
Expand Down
12 changes: 6 additions & 6 deletions crates/iota-sdk/src/apis/coin_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,16 @@ impl CoinReadApi {
/// let iota = IotaClientBuilder::default().build_localnet().await?;
/// let coin_metadata = iota
/// .coin_read_api()
/// .get_coin_metadata("0x2::iota::IOTA".to_string())
/// .get_coin_metadata("0x2::iota::IOTA")
/// .await?;
/// Ok(())
/// }
/// ```
pub async fn get_coin_metadata(
&self,
coin_type: String,
coin_type: impl Into<String>,
) -> IotaRpcResult<Option<IotaCoinMetadata>> {
Ok(self.api.http.get_coin_metadata(coin_type).await?)
Ok(self.api.http.get_coin_metadata(coin_type.into()).await?)
}

/// Return the total supply for a given coin type, or an error upon failure.
Expand All @@ -310,12 +310,12 @@ impl CoinReadApi {
/// let iota = IotaClientBuilder::default().build_localnet().await?;
/// let total_supply = iota
/// .coin_read_api()
/// .get_total_supply("0x2::iota::IOTA".to_string())
/// .get_total_supply("0x2::iota::IOTA")
/// .await?;
/// Ok(())
/// }
/// ```
pub async fn get_total_supply(&self, coin_type: String) -> IotaRpcResult<Supply> {
Ok(self.api.http.get_total_supply(coin_type).await?)
pub async fn get_total_supply(&self, coin_type: impl Into<String>) -> IotaRpcResult<Supply> {
Ok(self.api.http.get_total_supply(coin_type.into()).await?)
}
}

0 comments on commit c0cc650

Please sign in to comment.