From e6033ae324f0ca1e56d016d1d858dce2fa82cdee Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 18 Oct 2022 17:01:35 +0200 Subject: [PATCH] Avoid the usage of CanonicalAddr.0 --- packages/std/src/addresses.rs | 12 ++++++------ packages/std/src/imports.rs | 3 +-- packages/std/src/testing/mock.rs | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/std/src/addresses.rs b/packages/std/src/addresses.rs index 54ca2e1710..0cdffe45a0 100644 --- a/packages/std/src/addresses.rs +++ b/packages/std/src/addresses.rs @@ -499,17 +499,17 @@ mod tests { #[test] fn canonical_addr_implements_hash() { - let alice1 = CanonicalAddr(Binary::from([0, 187, 61, 11, 250, 0])); + let alice1 = CanonicalAddr::from([0, 187, 61, 11, 250, 0]); let mut hasher = DefaultHasher::new(); alice1.hash(&mut hasher); let alice1_hash = hasher.finish(); - let alice2 = CanonicalAddr(Binary::from([0, 187, 61, 11, 250, 0])); + let alice2 = CanonicalAddr::from([0, 187, 61, 11, 250, 0]); let mut hasher = DefaultHasher::new(); alice2.hash(&mut hasher); let alice2_hash = hasher.finish(); - let bob = CanonicalAddr(Binary::from([16, 21, 33, 0, 255, 9])); + let bob = CanonicalAddr::from([16, 21, 33, 0, 255, 9]); let mut hasher = DefaultHasher::new(); bob.hash(&mut hasher); let bob_hash = hasher.finish(); @@ -521,9 +521,9 @@ mod tests { /// This requires Hash and Eq to be implemented #[test] fn canonical_addr_can_be_used_in_hash_set() { - let alice1 = CanonicalAddr(Binary::from([0, 187, 61, 11, 250, 0])); - let alice2 = CanonicalAddr(Binary::from([0, 187, 61, 11, 250, 0])); - let bob = CanonicalAddr(Binary::from([16, 21, 33, 0, 255, 9])); + let alice1 = CanonicalAddr::from([0, 187, 61, 11, 250, 0]); + let alice2 = CanonicalAddr::from([0, 187, 61, 11, 250, 0]); + let bob = CanonicalAddr::from([16, 21, 33, 0, 255, 9]); let mut set = HashSet::new(); set.insert(alice1.clone()); diff --git a/packages/std/src/imports.rs b/packages/std/src/imports.rs index df03d1d640..f7438a9df0 100644 --- a/packages/std/src/imports.rs +++ b/packages/std/src/imports.rs @@ -1,7 +1,6 @@ use std::vec::Vec; use crate::addresses::{Addr, CanonicalAddr}; -use crate::binary::Binary; use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; use crate::import_helpers::{from_high_half, from_low_half}; use crate::memory::{alloc, build_region, consume_region, Region}; @@ -224,7 +223,7 @@ impl Api for ExternalApi { } let out = unsafe { consume_region(canon) }; - Ok(CanonicalAddr(Binary(out))) + Ok(CanonicalAddr::from(out)) } fn addr_humanize(&self, canonical: &CanonicalAddr) -> StdResult { diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index 0f74c3e3c1..f9681d1ccc 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -902,7 +902,7 @@ mod tests { #[should_panic(expected = "length not correct")] fn addr_humanize_input_length() { let api = MockApi::default(); - let input = CanonicalAddr(Binary(vec![61; 11])); + let input = CanonicalAddr::from(vec![61; 11]); api.addr_humanize(&input).unwrap(); }