|
1 | 1 | package api |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
4 | 5 | "math/big" |
5 | 6 |
|
6 | 7 | "github.com/ethereum/go-ethereum/common" |
| 8 | + "github.com/rocket-pool/smartnode/v2/rocketpool-cli/utils/terminal" |
7 | 9 | sharedtypes "github.com/rocket-pool/smartnode/v2/shared/types" |
8 | 10 | ) |
9 | 11 |
|
@@ -73,3 +75,30 @@ type NetworkDepositContractInfoData struct { |
73 | 75 | BeaconNetwork uint64 `json:"beaconNetwork"` |
74 | 76 | SufficientSync bool `json:"sufficientSync"` |
75 | 77 | } |
| 78 | + |
| 79 | +func (ndcid *NetworkDepositContractInfoData) Mismatched() bool { |
| 80 | + return ndcid.RPNetwork != ndcid.BeaconNetwork || |
| 81 | + ndcid.RPDepositContract != ndcid.BeaconDepositContract |
| 82 | +} |
| 83 | + |
| 84 | +func (ndcid *NetworkDepositContractInfoData) PrintMismatch() bool { |
| 85 | + if !ndcid.Mismatched() { |
| 86 | + fmt.Println("Your Beacon Node is on the correct network.") |
| 87 | + fmt.Println() |
| 88 | + return false |
| 89 | + } |
| 90 | + fmt.Printf("%s***ALERT***\n", terminal.ColorRed) |
| 91 | + fmt.Println("YOUR ETH2 CLIENT IS NOT CONNECTED TO THE SAME NETWORK THAT ROCKET POOL IS USING!") |
| 92 | + fmt.Println("This is likely because your ETH2 client is using the wrong configuration.") |
| 93 | + fmt.Println("For the safety of your funds, Rocket Pool will not let you deposit your ETH until this is resolved.") |
| 94 | + fmt.Println() |
| 95 | + fmt.Println("To fix it if you are in Docker mode:") |
| 96 | + fmt.Println("\t1. Run 'rocketpool service install -d' to get the latest configuration") |
| 97 | + fmt.Println("\t2. Run 'rocketpool service stop' and 'rocketpool service start' to apply the configuration.") |
| 98 | + fmt.Println("If you are using Hybrid or Native mode, please correct the network flags in your ETH2 launch script.") |
| 99 | + fmt.Println() |
| 100 | + fmt.Println("Details:") |
| 101 | + fmt.Printf("\tRocket Pool expects deposit contract %s on chain %d.\n", ndcid.RPDepositContract.Hex(), ndcid.RPNetwork) |
| 102 | + fmt.Printf("\tYour Beacon client is using deposit contract %s on chain %d.%s\n", ndcid.BeaconDepositContract.Hex(), ndcid.BeaconNetwork, terminal.ColorReset) |
| 103 | + return true |
| 104 | +} |
0 commit comments