diff --git a/packages/std/src/results/contract_result.rs b/packages/std/src/results/contract_result.rs index a54e71f6d6..364725e743 100644 --- a/packages/std/src/results/contract_result.rs +++ b/packages/std/src/results/contract_result.rs @@ -30,11 +30,11 @@ use std::fmt; /// assert_eq!(to_vec(&result).unwrap(), br#"{"error":"Something went wrong"}"#); /// ``` #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -pub enum ContractResult { +pub enum ContractResult { Ok(S), /// An error type that every custom error created by contract developers can be converted to. /// This could potientially have more structure, but String is the easiest. - Err(String), + Err(E), } // Implementations here mimic the Result API and should be implemented via a conversion to Result diff --git a/packages/std/src/traits.rs b/packages/std/src/traits.rs index 3a157f16df..2a31c37c6d 100644 --- a/packages/std/src/traits.rs +++ b/packages/std/src/traits.rs @@ -1,4 +1,4 @@ -use serde::{de::DeserializeOwned, Serialize}; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::marker::PhantomData; use std::ops::Deref; @@ -208,8 +208,17 @@ pub trait Api { fn ed25519_sign(&self, message: &[u8], private_key: &[u8]) -> Result, SigningError>; } +#[derive(Debug, Serialize, Deserialize, PartialEq)] +#[serde(rename_all = "snake_case")] +#[non_exhaustive] + +pub enum LegacyQueryResult { + /// Whenever there is no specific error type available + GenericErr { msg: String }, +} + /// A short-hand alias for the two-level query result (1. accessing the contract, 2. executing query in the contract) -pub type QuerierResult = SystemResult>; +pub type QuerierResult = SystemResult>; pub trait Querier { /// raw_query is all that must be implemented for the Querier. @@ -265,7 +274,7 @@ impl<'a, C: CustomQuery> QuerierWrapper<'a, C> { system_err ))), SystemResult::Ok(ContractResult::Err(contract_err)) => Err(StdError::generic_err( - format!("Querier contract error: {}", contract_err), + format!("Querier contract error: {:?}", contract_err), )), SystemResult::Ok(ContractResult::Ok(value)) => from_binary(&value), }