Struct clone_cw_multi_test::addons::MockApiBech32m
source · pub struct MockApiBech32m(/* private fields */);Expand description
Implementation of the Api trait that uses Bech32m format
for humanizing canonical addresses.
Implementations§
source§impl MockApiBech32m
impl MockApiBech32m
sourcepub fn new(prefix: &'static str) -> Self
pub fn new(prefix: &'static str) -> Self
Returns Api implementation that uses specified prefix
to generate addresses in Bech32m format.
§Example
use cw_multi_test::addons::MockApiBech32m;
let api = MockApiBech32m::new("osmosis");
let addr = api.addr_make("sender");
assert_eq!(addr.as_str(),
"osmosis1pgm8hyk0pvphmlvfjc8wsvk4daluz5tgrw6pu5mfpemk74uxnx9qgv9940");source§impl MockApiBech32m
impl MockApiBech32m
sourcepub fn addr_make(&self, input: &str) -> Addr
pub fn addr_make(&self, input: &str) -> Addr
Returns an address in Bech32m format, built from provided input string.
§Example
use cw_multi_test::addons::MockApiBech32m;
let api = MockApiBech32m::new("osmosis");
let addr = api.addr_make("sender");
assert_eq!(addr.as_str(),
"osmosis1pgm8hyk0pvphmlvfjc8wsvk4daluz5tgrw6pu5mfpemk74uxnx9qgv9940");§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 MockApiBech32m
impl Api for MockApiBech32m
source§fn addr_validate(&self, input: &str) -> StdResult<Addr>
fn addr_validate(&self, input: &str) -> StdResult<Addr>
Takes a human readable address in Bech32m 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::MockApiBech32m;
let api = MockApiBech32m::new("osmosis");
let addr = api.addr_make("sender");
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 Bech32m format and returns a canonical binary representation of it.
§Example
use cosmwasm_std::Api;
use cw_multi_test::addons::MockApiBech32;
let api = MockApiBech32::new("osmosis");
let addr = api.addr_make("sender");
assert_eq!(api.addr_canonicalize(addr.as_str()).unwrap().to_string(),
"0A367B92CF0B037DFD89960EE832D56F7FC151681BB41E53690E776F5786998A");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 Bech32m format.
This is the inverse operation of addr_canonicalize.
§Example
use cosmwasm_std::Api;
use cw_multi_test::addons::MockApiBech32m;
let api = MockApiBech32m::new("osmosis");
let addr = api.addr_make("sender");
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 MockApiBech32m
impl RefUnwindSafe for MockApiBech32m
impl Send for MockApiBech32m
impl Sync for MockApiBech32m
impl Unpin for MockApiBech32m
impl UnwindSafe for MockApiBech32m
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