Skip to content

Commit

Permalink
temparary solution for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
BoogVAr committed Jan 4, 2024
1 parent 7046183 commit 40769c4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 35 deletions.
5 changes: 2 additions & 3 deletions evm_loader/lib/src/abi/cancel_trx.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use super::params_to_neon_error;
use crate::commands::cancel_trx::{self, CancelTrxReturn};
use crate::commands::get_config::BuildConfigSimulator;
use crate::rpc::Rpc;
use crate::Config;
use crate::{types::CancelTrxRequest, NeonResult};
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::signer::Signer;

pub async fn execute(
rpc: &(impl Rpc + BuildConfigSimulator),
rpc: &RpcClient,
signer: &dyn Signer,
config: &Config,
params: &str,
Expand Down
9 changes: 3 additions & 6 deletions evm_loader/lib/src/abi/collect_treasury.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use crate::{
commands::{
collect_treasury::{self, CollectTreasuryReturn},
get_config::BuildConfigSimulator,
},
rpc::Rpc,
commands::collect_treasury::{self, CollectTreasuryReturn},
rpc::CloneRpcClient,
Config, NeonResult,
};
use solana_sdk::signer::Signer;

pub async fn execute(
rpc: &(impl Rpc + BuildConfigSimulator),
rpc: &CloneRpcClient,
signer: &dyn Signer,
config: &Config,
_params: &str,
Expand Down
5 changes: 2 additions & 3 deletions evm_loader/lib/src/abi/init_environment.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use super::params_to_neon_error;
use crate::commands::get_config::BuildConfigSimulator;
use crate::commands::init_environment::{self, InitEnvironmentReturn};
use crate::rpc::Rpc;
use crate::rpc::CloneRpcClient;
use crate::Config;
use crate::{types::InitEnvironmentRequest, NeonResult};
use solana_sdk::signer::Signer;

pub async fn execute(
rpc: &(impl Rpc + BuildConfigSimulator),
rpc: &CloneRpcClient,
signer: &dyn Signer,
config: &Config,
params: &str,
Expand Down
39 changes: 25 additions & 14 deletions evm_loader/lib/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod trace;

use crate::{
config::{self},
rpc::{CallDbClient, Rpc, RpcEnum},
rpc::{CallDbClient, RpcEnum},
types::{RequestWithSlot, TracerDb},
Config, LibMethods, NeonError,
};
Expand Down Expand Up @@ -89,14 +89,22 @@ async fn dispatch(method_str: &str, params_str: &str) -> Result<String, NeonErro
let singer = build_signer(&config)?;

match method {
LibMethods::CancelTrx => cancel_trx::execute(&rpc, &*singer, &config, params_str)
.await
.map(|v| serde_json::to_string(&v).unwrap()),
LibMethods::CollectTreasury => {
collect_treasury::execute(&rpc, &*singer, &config, params_str)
.await
.map(|v| serde_json::to_string(&v).unwrap())
}
LibMethods::CancelTrx => cancel_trx::execute(
&config.build_solana_rpc_client(),
&*singer,
&config,
params_str,
)
.await
.map(|v| serde_json::to_string(&v).unwrap()),
LibMethods::CollectTreasury => collect_treasury::execute(
&config.build_clone_solana_rpc_client(),
&*singer,
&config,
params_str,
)
.await
.map(|v| serde_json::to_string(&v).unwrap()),
LibMethods::Emulate => emulate::execute(&rpc, &config, params_str)
.await
.map(|v| serde_json::to_string(&v).unwrap()),
Expand All @@ -121,11 +129,14 @@ async fn dispatch(method_str: &str, params_str: &str) -> Result<String, NeonErro
LibMethods::Trace => trace::execute(&rpc, &config, params_str)
.await
.map(|v| serde_json::to_string(&v).unwrap()),
LibMethods::InitEnvironment => {
init_environment::execute(&rpc, &*singer, &config, params_str)
.await
.map(|v| serde_json::to_string(&v).unwrap())
} // _ => Err(NeonError::IncorrectLibMethod),
LibMethods::InitEnvironment => init_environment::execute(
&config.build_clone_solana_rpc_client(),
&*singer,
&config,
params_str,
)
.await
.map(|v| serde_json::to_string(&v).unwrap()), // _ => Err(NeonError::IncorrectLibMethod),
}
}

Expand Down
6 changes: 2 additions & 4 deletions evm_loader/lib/src/commands/cancel_trx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ use solana_sdk::{
signer::Signer,
};

use crate::{account_storage::account_info, commands::send_transaction, NeonResult, rpc::Rpc};

use super::get_config::BuildConfigSimulator;
use crate::{account_storage::account_info, commands::send_transaction, NeonResult};

#[derive(Debug, Serialize, Deserialize)]
pub struct CancelTrxReturn {
pub transaction: Signature,
}

pub async fn execute(
rpc_client: &(impl Rpc + BuildConfigSimulator),
rpc_client: &RpcClient,
signer: &dyn Signer,
evm_loader: Pubkey,
storage_account: &Pubkey,
Expand Down
2 changes: 0 additions & 2 deletions evm_loader/lib/src/commands/collect_treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use solana_sdk::{
use spl_token::instruction::sync_native;
use std::ops::Deref;

use super::get_config::BuildConfigSimulator;

#[derive(Debug, Serialize, Deserialize)]
pub struct CollectTreasuryReturn {
pub pool_address: String,
Expand Down
6 changes: 3 additions & 3 deletions evm_loader/rpc/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ pub async fn invoke(
tracing::debug!("ver {:?}", library.hash()());

let method_str: &str = method.into();
let params_str: string = "".to_string();
if let Some(params_str) = params {
params_str = serde_json::to_string(&params).unwrap();
let mut params_str: String = "".to_string();
if let Some(params_value) = params {
params_str = serde_json::to_string(&params_value).unwrap();
}

let result: Result<_, _> = library.invoke()(method_str.into(), params_str.as_str().into())
Expand Down

0 comments on commit 40769c4

Please sign in to comment.