Skip to content

Commit

Permalink
Merge pull request #299 from 0xcregis/298-fix-prepend-0x-to-ethereum-…
Browse files Browse the repository at this point in the history
…address

fix: prepend 0x to ETH address
  • Loading branch information
loki-cmu authored Nov 25, 2024
2 parents e5337b2 + f155d66 commit c5d0e38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/anychain-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "anychain-ethereum"
description = "A Rust library for Ethereum-focused cryptocurrency wallets, enabling seamless transactions on the Ethereum blockchain"
version = "0.1.20"
version = "0.1.21"
keywords = ["blockchain", "crypto", "ethereum", "wallet"]
categories = ["cryptography::cryptocurrencies"]

Expand Down
5 changes: 4 additions & 1 deletion crates/anychain-ethereum/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ impl FromStr for EthereumAddress {
}
let addr = addr.to_lowercase();
let _ = hex::decode(addr)?;
Ok(EthereumAddress(address.to_string()))
match address.starts_with("0x") {
true => Ok(EthereumAddress(address.to_string())),
false => Ok(EthereumAddress(format!("0x{}", address))),
}
}
}

Expand Down

0 comments on commit c5d0e38

Please sign in to comment.