use sp_core::crypto::{Ss58AddressFormat, Ss58Codec};
#[inline]
pub fn quantus_ss58_format() -> Ss58AddressFormat {
Ss58AddressFormat::custom(189)
}
pub trait QuantusSS58 {
fn to_quantus_ss58(&self) -> String;
}
impl QuantusSS58 for sp_core::crypto::AccountId32 {
fn to_quantus_ss58(&self) -> String {
self.to_ss58check_with_version(quantus_ss58_format())
}
}
impl QuantusSS58 for subxt::ext::subxt_core::utils::AccountId32 {
fn to_quantus_ss58(&self) -> String {
let bytes: [u8; 32] = *self.as_ref();
let sp_account_id = sp_core::crypto::AccountId32::from(bytes);
sp_account_id.to_ss58check_with_version(quantus_ss58_format())
}
}
pub fn bytes_to_quantus_ss58(bytes: &[u8; 32]) -> String {
let sp_account_id = sp_core::crypto::AccountId32::from(*bytes);
sp_account_id.to_ss58check_with_version(quantus_ss58_format())
}
pub fn slice_to_quantus_ss58(bytes: &[u8]) -> String {
let arr: [u8; 32] = bytes.try_into().expect("account must be 32 bytes");
bytes_to_quantus_ss58(&arr)
}