Skip to content

Commit

Permalink
chore: naming
Browse files Browse the repository at this point in the history
  • Loading branch information
royvardhan committed Dec 13, 2024
1 parent 181ea9a commit 1fb3d48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
13 changes: 8 additions & 5 deletions examples/erc20_gas/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ pub use post_execution::Erc20PostExecution;
pub use pre_execution::Erc20PreExecution;
pub use validation::Erc20Validation;

pub type Erc20Error<DB> = EVMError<<DB as Database>::Error, InvalidTransaction>;
pub type Erc20GasError<DB> = EVMError<<DB as Database>::Error, InvalidTransaction>;

pub type Erc20Context<DB> = Context<BlockEnv, TxEnv, CfgEnv, DB>;
pub type Erc20GasContext<DB> = Context<BlockEnv, TxEnv, CfgEnv, DB>;

pub type Erc20Handler<
pub type CustomHandler<
CTX,
ERROR,
VAL = Erc20Validation<CTX, ERROR>,
Expand All @@ -27,5 +27,8 @@ pub type Erc20Handler<
POSTEXEC = Erc20PostExecution<CTX, ERROR>,
> = EthHandler<CTX, ERROR, VAL, PREEXEC, EXEC, POSTEXEC>;

pub type Erc20Evm<DB> =
Evm<Erc20Error<DB>, Erc20Context<DB>, Erc20Handler<Erc20Context<DB>, Erc20Error<DB>>>;
pub type CustomEvm<DB> = Evm<
Erc20GasError<DB>,
Erc20GasContext<DB>,
CustomHandler<Erc20GasContext<DB>, Erc20GasError<DB>>,
>;
8 changes: 4 additions & 4 deletions examples/erc20_gas/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use revm::{
};

mod handlers;
use handlers::{Erc20Evm, Erc20Handler, Erc20PostExecution, Erc20PreExecution, Erc20Validation};
use handlers::{CustomEvm, CustomHandler, Erc20PostExecution, Erc20PreExecution, Erc20Validation};

type AlloyCacheDB =
CacheDB<WrapDatabaseAsync<AlloyDB<Http<Client>, Ethereum, RootProvider<Http<Client>>>>>;
Expand Down Expand Up @@ -142,7 +142,7 @@ fn balance_of(token: Address, address: Address, alloy_db: &mut AlloyCacheDB) ->
tx.data = encoded.into();
tx.value = U256::from(0);
}),
Erc20Handler::default(),
CustomHandler::default(),
);

let ref_tx = evm.exec_commit().unwrap();
Expand Down Expand Up @@ -172,7 +172,7 @@ fn transfer(

let encoded = transferCall { to, amount }.abi_encode();

let mut evm = Erc20Evm::new(
let mut evm = CustomEvm::new(
Context::builder()
.with_db(cache_db)
.modify_tx_chained(|tx| {
Expand All @@ -181,7 +181,7 @@ fn transfer(
tx.data = encoded.into();
tx.value = U256::from(0);
}),
Erc20Handler::new(
CustomHandler::new(
Erc20Validation::new(),
Erc20PreExecution::new(),
EthExecution::new(),
Expand Down

0 comments on commit 1fb3d48

Please sign in to comment.