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
// Copyright 2019-2023 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use serde::Serialize;

/// EVM actor method.
pub type Method = fil_actor_evm_state::v10::Method;

/// EVM actor state.
#[derive(Serialize, Debug)]
#[serde(untagged)]
pub enum State {
    V10(fil_actor_evm_state::v10::State),
    V11(fil_actor_evm_state::v11::State),
    V12(fil_actor_evm_state::v12::State),
    V13(fil_actor_evm_state::v13::State),
    V14(fil_actor_evm_state::v14::State),
}

impl State {
    pub fn nonce(&self) -> u64 {
        match self {
            State::V10(st) => st.nonce,
            State::V11(st) => st.nonce,
            State::V12(st) => st.nonce,
            State::V13(st) => st.nonce,
            State::V14(st) => st.nonce,
        }
    }

    pub fn is_alive(&self) -> bool {
        match self {
            State::V10(st) => st.tombstone.is_none(),
            State::V11(st) => st.tombstone.is_none(),
            State::V12(st) => st.tombstone.is_none(),
            State::V13(st) => st.tombstone.is_none(),
            State::V14(st) => st.tombstone.is_none(),
        }
    }
}