Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds impl Tokonizable for Bytes #313

Merged
merged 3 commits into from Jan 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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