Skip to content

Commit

Permalink
style: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
aya015757881 committed Jul 9, 2024
1 parent ca911b4 commit 5ab6583
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/address.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
use {
crate::{format::SolanaFormat, public_key::SolanaPublicKey}, anychain_core::{Address, AddressError, PublicKey, PublicKeyError}, core::{
crate::{format::SolanaFormat, public_key::SolanaPublicKey},
anychain_core::{Address, AddressError, PublicKey, PublicKeyError},
core::{
fmt::{Display, Formatter, Result as FmtResult},
str::FromStr,
}, ed25519_dalek::PUBLIC_KEY_LENGTH, solana_sdk::pubkey::Pubkey, spl_associated_token_account::get_associated_token_address
},
ed25519_dalek::PUBLIC_KEY_LENGTH,
solana_sdk::pubkey::Pubkey,
spl_associated_token_account::get_associated_token_address,
};

/// Represents a Solana address
Expand All @@ -11,10 +16,10 @@ pub struct SolanaAddress(pub String);

impl SolanaAddress {
pub fn associated_token_address(&self, token: String) -> Result<String, AddressError> {
let address = Pubkey::from_str(&self.0)
.map_err(|e| AddressError::Message(format!("{}", e)))?;
let token = Pubkey::from_str(&token)
.map_err(|e| AddressError::Message(format!("{}", e)))?;
let address =
Pubkey::from_str(&self.0).map_err(|e| AddressError::Message(format!("{}", e)))?;
let token =
Pubkey::from_str(&token).map_err(|e| AddressError::Message(format!("{}", e)))?;
let associated_token_address = get_associated_token_address(&address, &token);
Ok(associated_token_address.to_string())
}
Expand Down

0 comments on commit 5ab6583

Please sign in to comment.