Closed egasimus closed 7 months ago
you're mixing and matching encoding formats which happen to have the same underlying representation.
use namada_core::types::string_encoding::Format;
this API encodes addresses as "raw" addresses, which (tbh, confusingly) have discriminants different from borsh's for implicit and established addresses. try running this program:
use namada_core::types::address::Address;
use namada_core::types::string_encoding::Format;
use namada_core::borsh::*;
fn main() {
const ADDR: &str = "tnam1qqr8fld54cckvt2cc2e87z9s7eajm324usq5vkm9";
let addr = Address::decode(ADDR).unwrap();
let borsh_encoded_bytes = addr.serialize_to_vec();
let raw_addr_encoded_bytes = addr.to_bytes();
assert!(borsh_encoded_bytes != raw_addr_encoded_bytes);
println!("borsh_encoded_bytes: {borsh_encoded_bytes:02X?}");
println!("raw_addr_encoded_bytes: {raw_addr_encoded_bytes:02X?}");
}
and you'll see this output:
borsh_encoded_bytes: [01, 06, 74, FD, B4, AE, 31, 66, 2D, 58, C2, B2, 7F, 08, B0, F6, 7B, 2D, C5, 55, E4]
raw_addr_encoded_bytes: [00, 06, 74, FD, B4, AE, 31, 66, 2D, 58, C2, B2, 7F, 08, B0, F6, 7B, 2D, C5, 55, E4]
notice how the first bytes differ.
-- sugo
Querying
/vp/governance/proposal/200
, I get author address as the following 21 byte value:Here's what happens if I try to convert it to bech32m and back again, like so:
Output:
Looks like the 1st byte is switched around between
Implicit
andEstablished
.namadac query-account --owner tnam1qqr8fld54cckvt2cc2e87z9s7eajm324usq5vkm9
:namadac query-account --owner tnam1qqr8fld54cckvt2cc2e87z9s7eajm324usq5vkm9
: