Skip to content

Commit

Permalink
refactor: evm utils commands for velas binary
Browse files Browse the repository at this point in the history
  • Loading branch information
hrls authored and vldm committed Aug 25, 2021
1 parent 8a00d31 commit 3b3c33d
Show file tree
Hide file tree
Showing 12 changed files with 558 additions and 339 deletions.
25 changes: 5 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ members = [
"metrics",
"net-shaper",
"notifier",
"evm-utils",
"evm-utils/evm-bridge",
"evm-utils/programs/evm_loader",
"evm-utils/evm-state",
Expand Down
2 changes: 1 addition & 1 deletion bench-tps-evm/src/bench_evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl<'a> FundingTransactions<'a> for Vec<(&'a Keypair, &'a evm::SecretKey, Trans
let to_fund_txs: Vec<(&Keypair, &evm::SecretKey, Transaction)> = to_fund
.par_iter()
.map(|(k, evm)| {
let instructions = solana_evm_loader_program::transfer_native_to_eth_ixs(
let instructions = solana_evm_loader_program::transfer_native_to_evm_ixs(
k.pubkey(),
to_lamports,
evm.to_address(),
Expand Down
7 changes: 7 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ thiserror = "1.0.21"
tiny-bip39 = "0.7.0"
url = "2.1.1"

evm-state = { path = "../evm-utils/evm-state" }
evm-rpc = { path = "../evm-utils/evm-rpc" }
solana-evm-loader-program = { path = "../evm-utils/programs/evm_loader" }
hex = "0.4.2"
anyhow = { version = "1.0.42", features = ["std"] }


[dev-dependencies]
solana-core = { path = "../core", version = "=1.6.14" }
tempfile = "3.1.0"
Expand Down
17 changes: 15 additions & 2 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
cluster_query::*, feature::*, inflation::*, memo::*, nonce::*, program::*, spend_utils::*,
stake::*, validator_info::*, vote::*,
cluster_query::*, evm::*, feature::*, inflation::*, memo::*, nonce::*, program::*,
spend_utils::*, stake::*, validator_info::*, vote::*,
};
use clap::{value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand};
use log::*;
Expand Down Expand Up @@ -384,6 +384,8 @@ pub enum CliCommand {
derived_address_seed: Option<String>,
derived_address_program_id: Option<Pubkey>,
},
// Velas EVM Commands
Evm(EvmCliCommand),
}

#[derive(Debug, PartialEq)]
Expand Down Expand Up @@ -416,6 +418,9 @@ pub enum CliError {
KeypairFileNotFound(String),
#[error("incorrect loader provided: {0}")]
IncorrectLoader(String),

#[error("error caught: {0}")]
Other(#[from] anyhow::Error),
}

impl From<Box<dyn error::Error>> for CliError {
Expand Down Expand Up @@ -915,6 +920,8 @@ pub fn parse_command(
})
}
//
("evm", Some(matches)) => parse_evm_subcommand(matches),
//
("", None) => {
eprintln!("{}", matches.usage());
Err(CliError::CommandNotRecognized(
Expand Down Expand Up @@ -1085,6 +1092,7 @@ fn process_confirm(
confirmation_status: None,
transaction: None,
get_transaction_error: None,

err: None,
}
};
Expand Down Expand Up @@ -1919,6 +1927,10 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
derived_address_seed.clone(),
derived_address_program_id.as_ref(),
),
CliCommand::Evm(evm_subcommand) => evm_subcommand
.process_with(rpc_client.as_ref(), config)
.map(|_| "Ok".to_string())
.map_err(|e| Box::new(CliError::Other(e)) as Box<dyn std::error::Error>),
}
}

Expand Down Expand Up @@ -1989,6 +2001,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
.nonce_subcommands()
.program_subcommands()
.stake_subcommands()
.evm_subcommands()
.subcommand(
SubCommand::with_name("airdrop")
.about("Request lamports")
Expand Down
Loading

0 comments on commit 3b3c33d

Please sign in to comment.