From 0f028944e1f5b122adeecd1fb22c48a14853eda2 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 5 Jul 2022 12:07:28 -0700 Subject: [PATCH 1/2] Require TryFrom::Error to impl Debug --- sdk/src/env.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sdk/src/env.rs b/sdk/src/env.rs index aaca7fbb7..e7a71ebef 100644 --- a/sdk/src/env.rs +++ b/sdk/src/env.rs @@ -1,3 +1,5 @@ +use core::fmt::Debug; + #[cfg(target_family = "wasm")] pub mod internal { pub use stellar_contract_env_guest::*; @@ -93,9 +95,12 @@ impl Env { rv.try_into().unwrap() } - pub fn get_contract_data, V: IntoTryFromVal>(&self, key: K) -> V { + pub fn get_contract_data, V: IntoTryFromVal>(&self, key: K) -> V + where + V::Error: Debug, + { let rv = internal::Env::get_contract_data(self, key.into_val(self)); - V::try_from_val(&self, rv).map_err(|_| ()).unwrap() + V::try_from_val(self, rv).unwrap() } pub fn put_contract_data, V: IntoTryFromVal>(&self, key: K, val: V) { @@ -115,7 +120,7 @@ impl Env { pub fn deserialize_from_binary(&self, bin: Binary) -> V { let bin_obj: Object = RawVal::from(bin).try_into().unwrap(); let val_obj = internal::Env::deserialize_from_binary(self, bin_obj); - V::try_from_val(&self, val_obj.into_val(self)) + V::try_from_val(self, val_obj.into_val(self)) .map_err(|_| ()) .unwrap() } From 77961ec5812ac9f04a445633b69d63dd6338a34d Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 5 Jul 2022 12:11:13 -0700 Subject: [PATCH 2/2] remove other map_errs --- sdk/src/env.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sdk/src/env.rs b/sdk/src/env.rs index e7a71ebef..7d076cdfa 100644 --- a/sdk/src/env.rs +++ b/sdk/src/env.rs @@ -86,7 +86,7 @@ impl Env { pub fn get_invoking_contract(&self) -> ArrayBinary<32> { let rv = internal::Env::get_invoking_contract(self).to_raw(); - let bin = Binary::try_from_val(self, rv).map_err(|_| ()).unwrap(); + let bin = Binary::try_from_val(self, rv).unwrap(); bin.try_into().unwrap() } @@ -117,12 +117,13 @@ impl Env { bin_obj.in_env(self).try_into().unwrap() } - pub fn deserialize_from_binary(&self, bin: Binary) -> V { + pub fn deserialize_from_binary(&self, bin: Binary) -> V + where + V::Error: Debug, + { let bin_obj: Object = RawVal::from(bin).try_into().unwrap(); let val_obj = internal::Env::deserialize_from_binary(self, bin_obj); - V::try_from_val(self, val_obj.into_val(self)) - .map_err(|_| ()) - .unwrap() + V::try_from_val(self, val_obj.into_val(self)).unwrap() } pub fn compute_hash_sha256(&self, msg: Binary) -> Binary {