pub struct MockApiBech32 { /* private fields */ }Expand description
Implementation of the Api trait that uses Bech32 format
for humanizing canonical addresses.
Implementations§
Source§impl MockApiBech32
impl MockApiBech32
Sourcepub fn new(prefix: &str) -> Self
pub fn new(prefix: &str) -> Self
Returns Api implementation that uses specified prefix
to generate addresses in Bech32 format.
§Example
use cw_multi_test::addons::MockApiBech32;
let api = MockApiBech32::new("juno");
let addr = api.addr_make("creator");
assert_eq!(addr.as_str(),
"juno1h34lmpywh4upnjdg90cjf4j70aee6z8qqfspugamjp42e4q28kqsksmtyp");Source§impl MockApiBech32
impl MockApiBech32
Sourcepub fn addr_make(&self, input: &str) -> Addr
pub fn addr_make(&self, input: &str) -> Addr
Returns an address in Bech32 format, built from provided input string.
§Example
use cw_multi_test::addons::MockApiBech32;
let api = MockApiBech32::new("juno");
let addr = api.addr_make("creator");
assert_eq!(addr.as_str(),
"juno1h34lmpywh4upnjdg90cjf4j70aee6z8qqfspugamjp42e4q28kqsksmtyp");§Panics
This function panics when generating a valid address in Bech32 format is not possible, especially when prefix is too long or empty.
Trait Implementations§
Source§impl Api for MockApiBech32
impl Api for MockApiBech32
Source§fn addr_validate(&self, input: &str) -> StdResult<Addr>
fn addr_validate(&self, input: &str) -> StdResult<Addr>
Takes a human readable address in Bech32 format and checks if it is valid.
If the validation succeeds, an Addr containing the same string as the input is returned.
§Example
use cosmwasm_std::Api;
use cw_multi_test::addons::MockApiBech32;
let api = MockApiBech32::new("juno");
let addr = api.addr_make("creator");
assert_eq!(api.addr_validate(addr.as_str()).unwrap().as_str(),
addr.as_str());Source§fn addr_canonicalize(&self, input: &str) -> StdResult<CanonicalAddr>
fn addr_canonicalize(&self, input: &str) -> StdResult<CanonicalAddr>
Takes a human readable address in Bech32 format and returns a canonical binary representation of it.
§Example
use cosmwasm_std::Api;
use cw_multi_test::addons::MockApiBech32;
let api = MockApiBech32::new("juno");
let addr = api.addr_make("creator");
assert_eq!(api.addr_canonicalize(addr.as_str()).unwrap().to_string(),
"BC6BFD848EBD7819C9A82BF124D65E7F739D08E002601E23BB906AACD40A3D81");Source§fn addr_humanize(&self, canonical: &CanonicalAddr) -> StdResult<Addr>
fn addr_humanize(&self, canonical: &CanonicalAddr) -> StdResult<Addr>
Takes a canonical address and returns a human readable address in Bech32 format.
This is the inverse operation of addr_canonicalize.
§Example
use cosmwasm_std::Api;
use cw_multi_test::addons::MockApiBech32;
let api = MockApiBech32::new("juno");
let addr = api.addr_make("creator");
let canonical_addr = api.addr_canonicalize(addr.as_str()).unwrap();
assert_eq!(api.addr_humanize(&canonical_addr).unwrap().as_str(),
addr.as_str());fn secp256k1_verify( &self, message_hash: &[u8], signature: &[u8], public_key: &[u8], ) -> Result<bool, VerificationError>
fn secp256k1_recover_pubkey( &self, message_hash: &[u8], signature: &[u8], recovery_param: u8, ) -> Result<Vec<u8>, RecoverPubkeyError>
fn ed25519_verify( &self, message: &[u8], signature: &[u8], public_key: &[u8], ) -> Result<bool, VerificationError>
fn ed25519_batch_verify( &self, messages: &[&[u8]], signatures: &[&[u8]], public_keys: &[&[u8]], ) -> Result<bool, VerificationError>
Source§fn debug(&self, message: &str)
fn debug(&self, message: &str)
fn bls12_381_aggregate_g1( &self, g1s: &[u8], ) -> Result<[u8; 48], VerificationError>
fn bls12_381_aggregate_g2( &self, g2s: &[u8], ) -> Result<[u8; 96], VerificationError>
Source§fn bls12_381_pairing_equality(
&self,
ps: &[u8],
qs: &[u8],
r: &[u8],
s: &[u8],
) -> Result<bool, VerificationError>
fn bls12_381_pairing_equality( &self, ps: &[u8], qs: &[u8], r: &[u8], s: &[u8], ) -> Result<bool, VerificationError>
fn bls12_381_hash_to_g1( &self, hash_function: HashFunction, msg: &[u8], dst: &[u8], ) -> Result<[u8; 48], VerificationError>
fn bls12_381_hash_to_g2( &self, hash_function: HashFunction, msg: &[u8], dst: &[u8], ) -> Result<[u8; 96], VerificationError>
fn secp256r1_verify( &self, message_hash: &[u8], signature: &[u8], public_key: &[u8], ) -> Result<bool, VerificationError>
fn secp256r1_recover_pubkey( &self, message_hash: &[u8], signature: &[u8], recovery_param: u8, ) -> Result<Vec<u8>, RecoverPubkeyError>
Auto Trait Implementations§
impl Freeze for MockApiBech32
impl RefUnwindSafe for MockApiBech32
impl Send for MockApiBech32
impl Sync for MockApiBech32
impl Unpin for MockApiBech32
impl UnwindSafe for MockApiBech32
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request