Skip to content

Commit

Permalink
Update implementation of Tokenizable for Vec<u8>
Browse files Browse the repository at this point in the history
  • Loading branch information
ducthotran2010 committed Sep 24, 2020
1 parent 3c2cb53 commit 0396a44
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/contract/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,11 @@ tokenizable_item! {
impl Tokenizable for Vec<u8> {
fn from_token(token: Token) -> Result<Self, Error> {
match token {
Token::Bytes(data) => Ok(data),
Token::FixedBytes(data) => Ok(data),
other => Err(Error::InvalidOutputType(format!("Expected `bytes`, got {:?}", other))),
Token::Bytes(data) | Token::FixedBytes(data) => Ok(data),
Token::Array(tokens) | Token::FixedArray(tokens) => {
tokens.into_iter().map(Tokenizable::from_token).collect()
}
other => Err(Error::InvalidOutputType(format!("Expected `bytes` or `Array`, got {:?}", other))),
}
}
fn into_token(self) -> Token {
Expand Down

0 comments on commit 0396a44

Please sign in to comment.