Skip to content

Commit

Permalink
Merge pull request #84 from paritytech/td-clone
Browse files Browse the repository at this point in the history
Add couple of useful derives for generated structs.
  • Loading branch information
debris authored Feb 15, 2018
2 parents 39af9dd + 915a155 commit b59028d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 6 additions & 7 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ fn impl_ethabi_derive(ast: &syn::DeriveInput) -> Result<quote::Tokens> {
#(#logs_structs)*
}

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct #events_name {
}

Expand All @@ -85,6 +86,7 @@ fn impl_ethabi_derive(ast: &syn::DeriveInput) -> Result<quote::Tokens> {
#(#func_structs)*
}

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct #functions_name {
}
impl #functions_name {
Expand All @@ -107,16 +109,10 @@ fn impl_ethabi_derive(ast: &syn::DeriveInput) -> Result<quote::Tokens> {
const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error";

/// Contract
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct #name {
}

impl Default for #name {
fn default() -> Self {
#name {
}
}
}

impl #name {
#constructor_impl
}
Expand Down Expand Up @@ -403,6 +399,7 @@ fn declare_logs(event: &Event) -> quote::Tokens {
.collect();

quote! {
#[derive(Debug, Clone, PartialEq)]
pub struct #name {
#(#params)*
}
Expand Down Expand Up @@ -495,6 +492,7 @@ fn declare_events(event: &Event) -> quote::Tokens {


quote! {
#[derive(Debug, Clone, PartialEq)]
pub struct #name {
event: ethabi::Event,
}
Expand Down Expand Up @@ -650,6 +648,7 @@ fn declare_functions(function: &Function) -> quote::Tokens {
let function_constant = &function.constant;

quote! {
#[derive(Debug, Clone, PartialEq)]
pub struct #name {
function: ethabi::Function,
}
Expand Down
8 changes: 8 additions & 0 deletions tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ mod tests {
}
}

#[test]
fn should_be_cloneable() {
use validators::Validators;

let contract = Validators::default();
contract.clone();
}

#[test]
fn test_encoding_function_input_as_array() {
use validators::Validators;
Expand Down

0 comments on commit b59028d

Please sign in to comment.