diff --git a/rust/chains/tw_sui/src/address.rs b/rust/chains/tw_sui/src/address.rs index 1ed70526d86..063418906dc 100644 --- a/rust/chains/tw_sui/src/address.rs +++ b/rust/chains/tw_sui/src/address.rs @@ -57,7 +57,8 @@ impl FromStr for SuiAddress { impl fmt::Display for SuiAddress { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.0.to_hex_literal()) + let prefixed = true; + write!(f, "{}", hex::encode(self.0.as_ref(), prefixed)) } } @@ -86,4 +87,12 @@ mod tests { "0x259ff8074ab425cbb489f236e18e08f03f1a7856bdf7c7a2877bd64f738b5015" ); } + + /// https://github.com/trustwallet/wallet-core/issues/3837 + #[test] + fn test_sui_address_str_with_leading_zero() { + let s = "0x0cf10169225a251113b3198dc81d15ba72286f73353a8212f03bad10bd0f0a99"; + let addr = SuiAddress::from_str(s).unwrap(); + assert_eq!(addr.to_string(), s); + } } diff --git a/rust/tw_any_coin/tests/coin_address_derivation_test.rs b/rust/tw_any_coin/tests/coin_address_derivation_test.rs index 6be2411064a..2e9c4b0c018 100644 --- a/rust/tw_any_coin/tests/coin_address_derivation_test.rs +++ b/rust/tw_any_coin/tests/coin_address_derivation_test.rs @@ -153,7 +153,7 @@ fn test_coin_address_derivation() { CoinType::NativeZetaChain => "zeta14s0vgnj0pjnazu4hsqlksdk7slah9vcfcwctsr", CoinType::Dydx => "dydx1ten42eesehw0ktddcp0fws7d3ycsqez3kaamq3", CoinType::Solana => "5sn9QYhDaq61jLXJ8Li5BKqGL4DDMJQvU1rdN8XgVuwC", - CoinType::Sui => "0x1a5c6c1b74cec4fbd12b3e17252b83448136065afcdf24954dc3a9c26df4905", + CoinType::Sui => "0x01a5c6c1b74cec4fbd12b3e17252b83448136065afcdf24954dc3a9c26df4905", // end_of_coin_address_derivation_tests_marker_do_not_modify _ => panic!("{:?} must be covered", coin), };