forked from matter-labs/anvil-zksync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
evm.rs
67 lines (60 loc) · 2.15 KB
/
evm.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use zksync_basic_types::U64;
use zksync_web3_decl::error::Web3Error;
use crate::{
fork::ForkSource,
namespaces::{EvmNamespaceT, RpcResult},
node::InMemoryNode,
utils::{into_jsrpc_error, IntoBoxedFuture},
};
impl<S: ForkSource + std::fmt::Debug + Clone + Send + Sync + 'static> EvmNamespaceT
for InMemoryNode<S>
{
fn increase_time(&self, time_delta_seconds: u64) -> RpcResult<u64> {
self.increase_time(time_delta_seconds)
.map_err(|err| {
tracing::error!("failed increasing time: {:?}", err);
into_jsrpc_error(Web3Error::InternalError)
})
.into_boxed_future()
}
fn evm_mine(&self) -> RpcResult<String> {
self.mine_block()
.map_err(|err| {
tracing::error!("failed mining block: {:?}", err);
into_jsrpc_error(Web3Error::InternalError)
})
.into_boxed_future()
}
fn set_next_block_timestamp(&self, timestamp: u64) -> RpcResult<u64> {
self.set_next_block_timestamp(timestamp)
.map_err(|err| {
tracing::error!("failed setting time for next timestamp: {:?}", err);
into_jsrpc_error(Web3Error::InternalError)
})
.into_boxed_future()
}
fn set_time(&self, time: u64) -> RpcResult<i128> {
self.set_time(time)
.map_err(|err| {
tracing::error!("failed setting time: {:?}", err);
into_jsrpc_error(Web3Error::InternalError)
})
.into_boxed_future()
}
fn snapshot(&self) -> RpcResult<U64> {
self.snapshot()
.map_err(|err| {
tracing::error!("failed creating snapshot: {:?}", err);
into_jsrpc_error(Web3Error::InternalError)
})
.into_boxed_future()
}
fn revert_snapshot(&self, snapshot_id: U64) -> RpcResult<bool> {
self.revert_snapshot(snapshot_id)
.map_err(|err| {
tracing::error!("failed reverting snapshot: {:?}", err);
into_jsrpc_error(Web3Error::InternalError)
})
.into_boxed_future()
}
}