op_alloy_genesis/
addresses.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//! Address Types

use alloy_primitives::Address;

/// The set of network-specific contracts for a given chain.
#[derive(Debug, Clone, Hash, PartialEq, Eq, Default)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "PascalCase"))]
pub struct AddressList {
    /// The address manager
    pub address_manager: Address,
    /// L1 Cross Domain Messenger proxy address
    pub l1_cross_domain_messenger_proxy: Address,
    /// L1 ERC721 Bridge proxy address
    #[cfg_attr(feature = "serde", serde(alias = "L1ERC721BridgeProxy"))]
    pub l1_erc721_bridge_proxy: Address,
    /// L1 Standard Bridge proxy address
    pub l1_standard_bridge_proxy: Address,
    /// L2 Output Oracle Proxy address
    pub l2_output_oracle_proxy: Option<Address>,
    /// Optimism Mintable ERC20 Factory Proxy address
    #[cfg_attr(feature = "serde", serde(alias = "OptimismMintableERC20FactoryProxy"))]
    pub optimism_mintable_erc20_factory_proxy: Address,
    /// Optimism Portal Proxy address
    pub optimism_portal_proxy: Address,
    /// System Config Proxy address
    pub system_config_proxy: Address,
    /// The system config owner
    pub system_config_owner: Address,
    /// Proxy Admin address
    pub proxy_admin: Address,
    /// The owner of the Proxy Admin
    pub proxy_admin_owner: Address,
    /// The guardian address
    pub guardian: Address,

    // Fault Proof Contract Addresses
    /// Anchor State Registry Proxy address
    pub anchor_state_registry_proxy: Option<Address>,
    /// Delayed WETH Proxy address
    #[cfg_attr(feature = "serde", serde(alias = "DelayedWETHProxy"))]
    pub delayed_weth_proxy: Option<Address>,
    /// Dispute Game Factory Proxy address
    pub dispute_game_factory_proxy: Option<Address>,
    /// Fault Dispute Game Proxy address
    pub fault_dispute_game: Option<Address>,
    /// MIPS Proxy address
    #[cfg_attr(feature = "serde", serde(alias = "MIPS"))]
    pub mips: Option<Address>,
    /// Permissioned Dispute Game Proxy address
    pub permissioned_dispute_game: Option<Address>,
    /// Preimage Oracle Proxy address
    pub preimage_oracle: Option<Address>,
    /// The challenger's address
    pub challenger: Option<Address>,
}

impl AddressList {
    /// Sets zeroed addresses to [`Option::None`].
    pub fn zero_proof_addresses(&mut self) {
        if self.anchor_state_registry_proxy == Some(Address::ZERO) {
            self.anchor_state_registry_proxy = None;
        }
        if self.delayed_weth_proxy == Some(Address::ZERO) {
            self.delayed_weth_proxy = None;
        }
        if self.dispute_game_factory_proxy == Some(Address::ZERO) {
            self.dispute_game_factory_proxy = None;
        }
        if self.fault_dispute_game == Some(Address::ZERO) {
            self.fault_dispute_game = None;
        }
        if self.mips == Some(Address::ZERO) {
            self.mips = None;
        }
        if self.permissioned_dispute_game == Some(Address::ZERO) {
            self.permissioned_dispute_game = None;
        }
        if self.preimage_oracle == Some(Address::ZERO) {
            self.preimage_oracle = None;
        }
        if self.challenger == Some(Address::ZERO) {
            self.challenger = None;
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn zero_proof_addresses() {
        let mut addresses = AddressList {
            anchor_state_registry_proxy: Some(Address::ZERO),
            delayed_weth_proxy: Some(Address::ZERO),
            dispute_game_factory_proxy: Some(Address::ZERO),
            fault_dispute_game: Some(Address::ZERO),
            mips: Some(Address::ZERO),
            permissioned_dispute_game: Some(Address::ZERO),
            preimage_oracle: Some(Address::ZERO),
            challenger: Some(Address::ZERO),
            ..Default::default()
        };

        addresses.zero_proof_addresses();

        assert_eq!(addresses.anchor_state_registry_proxy, None);
        assert_eq!(addresses.delayed_weth_proxy, None);
        assert_eq!(addresses.dispute_game_factory_proxy, None);
        assert_eq!(addresses.fault_dispute_game, None);
        assert_eq!(addresses.mips, None);
        assert_eq!(addresses.permissioned_dispute_game, None);
        assert_eq!(addresses.preimage_oracle, None);
        assert_eq!(addresses.challenger, None);
    }
}