example_erc20_gas/
exec.rs1use crate::handler::Erc20MainetHandler;
2use revm::{
3 context_interface::{
4 result::{EVMError, ExecutionResult, HaltReason, InvalidTransaction, ResultAndState},
5 ContextTr, Journal,
6 },
7 database_interface::DatabaseCommit,
8 handler::{
9 instructions::InstructionProvider, ContextTrDbError, EthFrame, EvmTr, Handler,
10 PrecompileProvider,
11 },
12 interpreter::{interpreter::EthInterpreter, InterpreterAction, InterpreterResult},
13 primitives::Log,
14 state::EvmState,
15};
16
17pub fn transact_erc20evm<EVM>(
18 evm: &mut EVM,
19) -> Result<ResultAndState<HaltReason>, EVMError<ContextTrDbError<EVM::Context>, InvalidTransaction>>
20where
21 EVM: EvmTr<
22 Context: ContextTr<Journal: Journal<FinalOutput = (EvmState, Vec<Log>)>>,
23 Precompiles: PrecompileProvider<Context = EVM::Context, Output = InterpreterResult>,
24 Instructions: InstructionProvider<
25 Context = EVM::Context,
26 InterpreterTypes = EthInterpreter,
27 Output = InterpreterAction,
28 >,
29 >,
30{
31 Erc20MainetHandler::<EVM, _, EthFrame<EVM, _, EthInterpreter>>::new().run(evm)
32}
33
34pub fn transact_erc20evm_commit<EVM>(
35 evm: &mut EVM,
36) -> Result<ExecutionResult<HaltReason>, EVMError<ContextTrDbError<EVM::Context>, InvalidTransaction>>
37where
38 EVM: EvmTr<
39 Context: ContextTr<
40 Journal: Journal<FinalOutput = (EvmState, Vec<Log>)>,
41 Db: DatabaseCommit,
42 >,
43 Precompiles: PrecompileProvider<Context = EVM::Context, Output = InterpreterResult>,
44 Instructions: InstructionProvider<
45 Context = EVM::Context,
46 InterpreterTypes = EthInterpreter,
47 Output = InterpreterAction,
48 >,
49 >,
50{
51 transact_erc20evm(evm).map(|r| {
52 evm.ctx().db().commit(r.state);
53 r.result
54 })
55}