|
| 1 | +/* |
| 2 | + * Copyright contributors to Hyperledger Besu. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 5 | + * the License. You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 10 | + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 11 | + * specific language governing permissions and limitations under the License. |
| 12 | + * |
| 13 | + * SPDX-License-Identifier: Apache-2.0 |
| 14 | + */ |
| 15 | +package org.hyperledger.besu.ethereum.mainnet.requests; |
| 16 | + |
| 17 | +import static org.hyperledger.besu.ethereum.mainnet.requests.ConsolidationRequestProcessor.CONSOLIDATION_REQUEST_CONTRACT_ADDRESS; |
| 18 | +import static org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor.DEFAULT_DEPOSIT_CONTRACT_ADDRESS; |
| 19 | +import static org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestProcessor.DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS; |
| 20 | + |
| 21 | +import org.hyperledger.besu.config.GenesisConfigOptions; |
| 22 | +import org.hyperledger.besu.datatypes.Address; |
| 23 | + |
| 24 | +public class RequestContractAddresses { |
| 25 | + private final Address withdrawalRequestContractAddress; |
| 26 | + private final Address depositContractAddress; |
| 27 | + private final Address consolidationRequestContractAddress; |
| 28 | + |
| 29 | + public RequestContractAddresses( |
| 30 | + final Address withdrawalRequestContractAddress, |
| 31 | + final Address depositContractAddress, |
| 32 | + final Address consolidationRequestContractAddress) { |
| 33 | + this.withdrawalRequestContractAddress = withdrawalRequestContractAddress; |
| 34 | + this.depositContractAddress = depositContractAddress; |
| 35 | + this.consolidationRequestContractAddress = consolidationRequestContractAddress; |
| 36 | + } |
| 37 | + |
| 38 | + public static RequestContractAddresses fromGenesis( |
| 39 | + final GenesisConfigOptions genesisConfigOptions) { |
| 40 | + return new RequestContractAddresses( |
| 41 | + genesisConfigOptions |
| 42 | + .getWithdrawalRequestContractAddress() |
| 43 | + .orElse(DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS), |
| 44 | + genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS), |
| 45 | + genesisConfigOptions |
| 46 | + .getConsolidationRequestContractAddress() |
| 47 | + .orElse(CONSOLIDATION_REQUEST_CONTRACT_ADDRESS)); |
| 48 | + } |
| 49 | + |
| 50 | + public Address getWithdrawalRequestContractAddress() { |
| 51 | + return withdrawalRequestContractAddress; |
| 52 | + } |
| 53 | + |
| 54 | + public Address getDepositContractAddress() { |
| 55 | + return depositContractAddress; |
| 56 | + } |
| 57 | + |
| 58 | + public Address getConsolidationRequestContractAddress() { |
| 59 | + return consolidationRequestContractAddress; |
| 60 | + } |
| 61 | +} |
0 commit comments