Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 14 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
[package]
name = "dapptools"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
structopt = "0.3.22"
# ethers = "0.5.2"
ethers = { git = "https://github.com/gakonst/ethers-rs", branch = "chore/update-ethabi" }

eyre = "0.6.5"
tokio = { version = "1.10.1", features = ["macros"] }
rustc-hex = "2.1.0"
serde_json = "1.0.67"
rpassword = "5.0.1"
evm = { version = "0.30.1" }
ansi_term = "0.12.1"
serde = "1.0.130"
hex = "0.4.3"
regex = { version = "1.5.4", default-features = false }

svm = { package = "svm-rs", git = "https://github.com/roynalnaruto/svm-rs" }
glob = "0.3.0"
semver = "1.0.4"

[patch.'crates-io']
evm = { git = "https://github.com/gakonst/evm" }
[workspace]
members = [
"utils",
"seth",
"dapp",
"dapptools",
]

# Binary size optimizations
[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
25 changes: 25 additions & 0 deletions dapp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "dapp"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dapp-utils = { path = "./../utils" }

# evm = { version = "0.30.1" }
evm = { git = "https://github.com/gakonst/evm" }
# ethers = { version = "0.5.2" }
ethers = { git = "https://github.com/gakonst/ethers-rs", branch = "master" }
svm = { package = "svm-rs", git = "https://github.com/roynalnaruto/svm-rs" }

eyre = "0.6.5"
semver = "1.0.4"
serde_json = "1.0.67"
serde = "1.0.130"
regex = { version = "1.5.4", default-features = false }
hex = "0.4.3"
glob = "0.3.0"
# TODO: Trim
tokio = { version = "1.10.1" }
File renamed without changes.
5 changes: 4 additions & 1 deletion src/dapp.rs → dapp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ use std::{
path::{Path, PathBuf},
};

/// Re-export of the Rust EVM for convenience
pub use evm;

use eyre::Result;
use regex::Regex;

use crate::utils::get_func;
use dapp_utils::get_func;

// TODO: Check if we can implement this as the base layer of an ethers-provider
// Middleware stack instead of doing RPC calls.
Expand Down
30 changes: 30 additions & 0 deletions dapptools/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "dapptools"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
structopt = "0.3.23"
dapp-utils = { path = "../utils" }
dapp = { path = "../dapp" }
seth = { path = "../seth" }

# ethers = "0.5"
ethers = { git = "https://github.com/gakonst/ethers-rs", branch = "master" }
eyre = "0.6.5"
rustc-hex = "2.1.0"
serde_json = "1.0.67"
tokio = { version = "1.11.0", features = ["macros"] }
regex = { version = "1.5.4", default-features = false }
ansi_term = "0.12.1"
rpassword = "5.0.1"

[[bin]]
name = "seth"
path = "src/seth.rs"

[[bin]]
name = "dapp"
path = "src/dapp.rs"
6 changes: 4 additions & 2 deletions src/bin/dapp.rs → dapptools/src/dapp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use structopt::StructOpt;

use dapptools::dapp::MultiContractRunner;
use evm::{backend::MemoryVicinity, Config};
use dapp::{
evm::{backend::MemoryVicinity, Config},
MultiContractRunner,
};

use ansi_term::Colour;
use std::{
Expand Down
74 changes: 6 additions & 68 deletions src/opts.rs → dapptools/src/opts.rs
Original file line number Diff line number Diff line change
@@ -1,76 +1,13 @@
use ethers::types::Address;
use ethers::{prelude::*, signers::coins_bip39::English};
use ethers::{
providers::{Http, Provider},
signers::{coins_bip39::English, LocalWallet, MnemonicBuilder},
types::Address,
};
use eyre::Result;
use std::convert::TryFrom;
use std::str::FromStr;
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
#[structopt(about = "Perform Ethereum RPC calls from the comfort of your command line.")]
pub enum Subcommands {
#[structopt(name = "--from-ascii")]
#[structopt(about = "convert text data into hexdata")]
FromAscii { text: String },
#[structopt(name = "--to-checksum-address")]
#[structopt(about = "convert an address to a checksummed format (EIP-55)")]
ToCheckSumAddress { address: Address },
#[structopt(name = "--to-bytes32")]
#[structopt(about = "left-pads a hex bytes string to 32 bytes)")]
ToBytes32 { bytes: String },
#[structopt(name = "block")]
#[structopt(
about = "Prints information about <block>. If <field> is given, print only the value of that field"
)]
Block {
#[structopt(help = "the block you want to query, can also be earliest/latest/pending", parse(try_from_str = parse_block_id))]
block: BlockId,
#[structopt(long, env = "SETH_FULL_BLOCK")]
full: bool,
field: Option<String>,
#[structopt(long = "--json", short = "-j")]
to_json: bool,
#[structopt(long, env = "ETH_RPC_URL")]
rpc_url: String,
},
#[structopt(name = "call")]
#[structopt(about = "Perform a local call to <to> without publishing a transaction.")]
Call {
#[structopt(help = "the address you want to query")]
address: Address,
sig: String,
args: Vec<String>,
#[structopt(long, env = "ETH_RPC_URL")]
rpc_url: String,
},
#[structopt(name = "send")]
#[structopt(about = "Publish a transaction signed by <from> to call <to> with <data>")]
SendTx {
#[structopt(help = "the address you want to transact with")]
to: Address,
#[structopt(help = "the function signature you want to call")]
sig: String,
#[structopt(help = "the list of arguments you want to call the function with")]
args: Vec<String>,
#[structopt(flatten)]
eth: EthereumOpts,
},
}

fn parse_block_id(s: &str) -> eyre::Result<BlockId> {
Ok(match s {
"earliest" => BlockId::Number(BlockNumber::Earliest),
"latest" => BlockId::Number(BlockNumber::Latest),
s if s.starts_with("0x") => BlockId::Hash(H256::from_str(s)?),
s => BlockId::Number(BlockNumber::Number(U64::from_str(s)?)),
})
}

#[derive(Debug, StructOpt)]
pub struct Opts {
#[structopt(subcommand)]
pub sub: Subcommands,
}

#[derive(StructOpt, Debug, Clone)]
pub struct EthereumOpts {
#[structopt(
Expand All @@ -94,6 +31,7 @@ pub struct EthereumOpts {
// TODO: Improve these so that we return a middleware trait object
use std::sync::Arc;
impl EthereumOpts {
#[allow(unused)]
pub fn provider(&self) -> eyre::Result<Arc<Provider<Http>>> {
Ok(Arc::new(Provider::try_from(self.rpc_url.as_str())?))
}
Expand Down
77 changes: 72 additions & 5 deletions src/bin/seth.rs → dapptools/src/seth.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,82 @@
use std::convert::TryFrom;
mod opts;
use opts::EthereumOpts;

use seth::{Seth, SimpleSeth};

use ethers::{
prelude::SignerMiddleware,
middleware::SignerMiddleware,
providers::{Middleware, Provider},
signers::Signer,
types::Address,
types::{Address, BlockId, BlockNumber, H256, U64},
};
use std::{convert::TryFrom, str::FromStr};
use structopt::StructOpt;

use dapptools::opts::{Opts, Subcommands};
use dapptools::{Seth, SimpleSeth};
#[derive(Debug, StructOpt)]
#[structopt(about = "Perform Ethereum RPC calls from the comfort of your command line.")]
pub enum Subcommands {
#[structopt(name = "--from-ascii")]
#[structopt(about = "convert text data into hexdata")]
FromAscii { text: String },
#[structopt(name = "--to-checksum-address")]
#[structopt(about = "convert an address to a checksummed format (EIP-55)")]
ToCheckSumAddress { address: Address },
#[structopt(name = "--to-bytes32")]
#[structopt(about = "left-pads a hex bytes string to 32 bytes)")]
ToBytes32 { bytes: String },
#[structopt(name = "block")]
#[structopt(
about = "Prints information about <block>. If <field> is given, print only the value of that field"
)]
Block {
#[structopt(help = "the block you want to query, can also be earliest/latest/pending", parse(try_from_str = parse_block_id))]
block: BlockId,
#[structopt(long, env = "SETH_FULL_BLOCK")]
full: bool,
field: Option<String>,
#[structopt(long = "--json", short = "-j")]
to_json: bool,
#[structopt(long, env = "ETH_RPC_URL")]
rpc_url: String,
},
#[structopt(name = "call")]
#[structopt(about = "Perform a local call to <to> without publishing a transaction.")]
Call {
#[structopt(help = "the address you want to query")]
address: Address,
sig: String,
args: Vec<String>,
#[structopt(long, env = "ETH_RPC_URL")]
rpc_url: String,
},
#[structopt(name = "send")]
#[structopt(about = "Publish a transaction signed by <from> to call <to> with <data>")]
SendTx {
#[structopt(help = "the address you want to transact with")]
to: Address,
#[structopt(help = "the function signature you want to call")]
sig: String,
#[structopt(help = "the list of arguments you want to call the function with")]
args: Vec<String>,
#[structopt(flatten)]
eth: EthereumOpts,
},
}

fn parse_block_id(s: &str) -> eyre::Result<BlockId> {
Ok(match s {
"earliest" => BlockId::Number(BlockNumber::Earliest),
"latest" => BlockId::Number(BlockNumber::Latest),
s if s.starts_with("0x") => BlockId::Hash(H256::from_str(s)?),
s => BlockId::Number(BlockNumber::Number(U64::from_str(s)?)),
})
}

#[derive(Debug, StructOpt)]
pub struct Opts {
#[structopt(subcommand)]
pub sub: Subcommands,
}

#[tokio::main]
async fn main() -> eyre::Result<()> {
Expand Down
15 changes: 15 additions & 0 deletions seth/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "seth"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dapp-utils = { path = "../utils" }
# ethers = "0.5"
ethers-core = { git = "https://github.com/gakonst/ethers-rs", branch = "master", default-features = false }
ethers-providers = { git = "https://github.com/gakonst/ethers-rs", branch = "master", default-features = false }
eyre = "0.6.5"
rustc-hex = "2.1.0"
serde_json = "1.0.67"
Loading