-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #500 from CosmWasm/HandleMsg_UserErrorsInApiCalls
Add HandleMsg::UserErrorsInApiCalls to hackatom
- Loading branch information
Showing
12 changed files
with
250 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
use std::fmt; | ||
|
||
use crate::encoding::Binary; | ||
|
||
// Added Eq and Hash to allow this to be a key in a HashMap (MockQuerier) | ||
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq, JsonSchema, Hash)] | ||
pub struct HumanAddr(pub String); | ||
|
||
impl HumanAddr { | ||
pub fn as_str(&self) -> &str { | ||
&self.0 | ||
} | ||
|
||
pub fn len(&self) -> usize { | ||
self.0.len() | ||
} | ||
|
||
pub fn is_empty(&self) -> bool { | ||
self.0.is_empty() | ||
} | ||
} | ||
|
||
impl fmt::Display for HumanAddr { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}", &self.0) | ||
} | ||
} | ||
|
||
impl From<&str> for HumanAddr { | ||
fn from(addr: &str) -> Self { | ||
HumanAddr(addr.to_string()) | ||
} | ||
} | ||
|
||
impl From<&HumanAddr> for HumanAddr { | ||
fn from(addr: &HumanAddr) -> Self { | ||
HumanAddr(addr.0.to_string()) | ||
} | ||
} | ||
|
||
impl From<&&HumanAddr> for HumanAddr { | ||
fn from(addr: &&HumanAddr) -> Self { | ||
HumanAddr(addr.0.to_string()) | ||
} | ||
} | ||
|
||
impl From<String> for HumanAddr { | ||
fn from(addr: String) -> Self { | ||
HumanAddr(addr) | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, JsonSchema)] | ||
pub struct CanonicalAddr(pub Binary); | ||
|
||
impl From<&[u8]> for CanonicalAddr { | ||
fn from(source: &[u8]) -> Self { | ||
Self(source.into()) | ||
} | ||
} | ||
|
||
impl From<Vec<u8>> for CanonicalAddr { | ||
fn from(source: Vec<u8>) -> Self { | ||
Self(source.into()) | ||
} | ||
} | ||
|
||
impl CanonicalAddr { | ||
pub fn as_slice(&self) -> &[u8] { | ||
&self.0.as_slice() | ||
} | ||
|
||
pub fn len(&self) -> usize { | ||
self.0.len() | ||
} | ||
|
||
pub fn is_empty(&self) -> bool { | ||
self.0.is_empty() | ||
} | ||
} | ||
|
||
impl fmt::Display for CanonicalAddr { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
self.0.fmt(f) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.