Skip to content

Commit

Permalink
Adds impl Tokonizable for Bytes (#313)
Browse files Browse the repository at this point in the history
* Added the impl Tokenizable for Bytes

* Changed the order of types

* Removed the needless empty line
  • Loading branch information
chabashilah authored and tomusdrw committed Jan 27, 2020
1 parent ab42618 commit bd81498
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/contract/tokens.rs
@@ -1,7 +1,7 @@
//! Contract Functions Output types.

use crate::contract::error::Error;
use crate::types::{Address, H256, U128, U256};
use crate::types::{Address, Bytes, H256, U128, U256};
use arrayvec::ArrayVec;
use ethabi::Token;

Expand Down Expand Up @@ -156,6 +156,19 @@ impl Tokenizable for String {
}
}

impl Tokenizable for Bytes {
fn from_token(token: Token) -> Result<Self, Error> {
match token {
Token::Bytes(s) => Ok(s.into()),
other => Err(Error::InvalidOutputType(format!("Expected `Bytes`, got {:?}", other))),
}
}

fn into_token(self) -> Token {
Token::Bytes(self.0)
}
}

impl Tokenizable for H256 {
fn from_token(token: Token) -> Result<Self, Error> {
match token {
Expand Down

0 comments on commit bd81498

Please sign in to comment.