chore(abigen): remove unnecessary stuff

This commit is contained in:
Georgios Konstantopoulos 2020-06-10 22:46:55 +03:00
parent f562b47fd2
commit aa454b945b
No known key found for this signature in database
GPG Key ID: FA607837CD26EDBC
5 changed files with 0 additions and 229 deletions

View File

@ -1,55 +0,0 @@
# `ethcontract-generate`
An alternative API for generating type-safe contract bindings from `build.rs`
scripts. Using this method instead of the procedural macro has a couple
advantages:
- Proper integration with with RLS and Racer for autocomplete support
- Ability to inspect the generated code
The downside of using the generator API is the requirement of having a build
script instead of a macro invocation.
## Getting Started
Using crate requires two dependencies - one for the runtime and one for the
generator:
```toml
[dependencies]
ethcontract = { version = "...", default-features = false }
[build-dependencies]
ethcontract-generate = "..."
```
It is recommended that both versions be kept in sync or else unexpected
behaviour may occur.
Then, in your `build.rs` include the following code:
```rs
use ethcontract_generate::Builder;
use std::env;
use std::path::Path;
fn main() {
let dest = env::var("OUT_DIR").unwrap();
Builder::new("path/to/truffle/build/contract/Contract.json")
.generate()
.unwrap()
.write_to_file(Path::new(&dest).join("rust_coin.rs"))
.unwrap();
}
```
## Relation to `ethcontract-derive`
`ethcontract-derive` uses `ethcontract-generate` under the hood so their
generated bindings should be identical, they just provide different APIs to the
same functionality.
The long term goal of this project is to maintain `ethcontract-derive`. For now
there is no extra work in having it split into two separate crates. That being
said if RLS support improves for procedural macro generated code, it is possible
that this crate be deprecated in favour of `ethcontract-derive` as long as there
is no good argument to keep it around.

View File

@ -1 +0,0 @@
[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"name","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"symbol","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"decimals","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"totalSupply","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"who","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]

View File

@ -1,10 +0,0 @@
use ethers_contract_abigen::Abigen;
fn main() {
Abigen::new("ERC20Token", "./abi.json")
.unwrap()
.generate()
.unwrap()
.write_to_file("token.rs")
.unwrap();
}

View File

@ -1,9 +1,4 @@
#![deny(missing_docs)] #![deny(missing_docs)]
//! Crate for generating type-safe bindings to Ethereum smart contracts. This
//! crate is intended to be used either indirectly with the `ethcontract`
//! crate's `contract` procedural macro or directly from a build script.
mod common; mod common;
mod events; mod events;
mod methods; mod methods;

View File

@ -327,46 +327,6 @@ mod tests {
}); });
} }
// #[test]
// fn expand_transfer_builder_topic_filters() {
// let event = Event {
// name: "Transfer".into(),
// inputs: vec![
// EventParam {
// name: "from".into(),
// kind: ParamType::Address,
// indexed: true,
// },
// EventParam {
// name: "to".into(),
// kind: ParamType::Address,
// indexed: true,
// },
// EventParam {
// name: "amount".into(),
// kind: ParamType::Uint(256),
// indexed: false,
// },
// ],
// anonymous: false,
// };
// #[rustfmt::skip]
// assert_quote!(expand_builder_topic_filters(&event).unwrap(), {
// #[doc = "Adds a filter for the from event parameter."]
// pub fn from(mut self, topic: self::ethcontract::Topic<self::ethcontract::Address>) -> Self {
// self.0 = (self.0).topic0(topic);
// self
// }
// #[doc = "Adds a filter for the to event parameter."]
// pub fn to(mut self, topic: self::ethcontract::Topic<self::ethcontract::Address>) -> Self {
// self.0 = (self.0).topic1(topic);
// self
// }
// });
// }
#[test] #[test]
fn expand_data_struct_value() { fn expand_data_struct_value() {
let event = Event { let event = Event {
@ -428,124 +388,6 @@ mod tests {
assert_quote!(construction, { FooFilter(p0, p1) }); assert_quote!(construction, { FooFilter(p0, p1) });
} }
// #[test]
// fn expand_enum_for_all_events() {
// let context = {
// let mut context = Context::default();
// context.abi.events.insert(
// "Foo".into(),
// vec![Event {
// name: "Foo".into(),
// inputs: vec![EventParam {
// name: String::new(),
// kind: ParamType::Bool,
// indexed: false,
// }],
// anonymous: false,
// }],
// );
// context.abi.events.insert(
// "Bar".into(),
// vec![Event {
// name: "Bar".into(),
// inputs: vec![EventParam {
// name: String::new(),
// kind: ParamType::Address,
// indexed: false,
// }],
// anonymous: true,
// }],
// );
// context.event_derives = ["Asdf", "a::B", "a::b::c::D"]
// .iter()
// .map(|derive| syn::parse_str::<Path>(derive).unwrap())
// .collect();
// context
// };
// assert_quote!(expand_event_enum(&context), {
// /// A contract event.
// #[derive(Clone, Debug, Eq, PartialEq, Asdf, a::B, a::b::c::D)]
// pub enum Event {
// Bar(self::event_data::Bar),
// Foo(self::event_data::Foo),
// }
// });
// }
#[test]
// fn expand_parse_log_impl_for_all_events() {
// let context = {
// let mut context = Context::default();
// context.abi.events.insert(
// "Foo".into(),
// vec![Event {
// name: "Foo".into(),
// inputs: vec![EventParam {
// name: String::new(),
// kind: ParamType::Bool,
// indexed: false,
// }],
// anonymous: false,
// }],
// );
// context.abi.events.insert(
// "Bar".into(),
// vec![Event {
// name: "Bar".into(),
// inputs: vec![EventParam {
// name: String::new(),
// kind: ParamType::Address,
// indexed: false,
// }],
// anonymous: true,
// }],
// );
// context
// };
// let foo_signature = expand_hash(context.abi.event("Foo").unwrap().signature());
// let invalid_data = expand_invalid_data();
// assert_quote!(expand_event_parse_log(&context), {
// impl self::ethcontract::contract::ParseLog for Event {
// fn parse_log(
// log: self::ethcontract::RawLog,
// ) -> Result<Self, self::ethcontract::errors::ExecutionError> {
// let standard_event = log.topics
// .get(0)
// .copied()
// .map(|topic| match topic {
// #foo_signature => Ok(Event::Foo(
// log.clone().decode(
// &Contract::artifact()
// .abi
// .event("Foo")
// .expect("generated event decode")
// )?
// )),
// _ => #invalid_data,
// });
// if let Some(Ok(data)) = standard_event {
// return Ok(data);
// }
// if let Ok(data) = log.clone().decode(
// &Contract::artifact()
// .abi
// .event("Bar")
// .expect("generated event decode")
// ) {
// return Ok(Event::Bar(data));
// }
// #invalid_data
// }
// }
// });
// }
#[test] #[test]
#[rustfmt::skip] #[rustfmt::skip]
fn expand_hash_value() { fn expand_hash_value() {