mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
Progress with account_manager deposit tools
This commit is contained in:
@@ -12,3 +12,4 @@ tempdir = "0.3"
|
||||
[dependencies]
|
||||
serde = "1.0"
|
||||
serde_json = "^1.0"
|
||||
types = { path = "../../types"}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
use std::fs::{create_dir_all, File};
|
||||
use std::path::PathBuf;
|
||||
use types::Address;
|
||||
|
||||
pub const ADDRESS_FILE: &str = "deposit_contract.txt";
|
||||
pub const DEPLOY_BLOCK_FILE: &str = "deploy_block.txt";
|
||||
@@ -16,7 +17,7 @@ pub const MIN_GENESIS_TIME_FILE: &str = "min_genesis_time.txt";
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Eth2TestnetDir {
|
||||
pub deposit_contract_address: String,
|
||||
deposit_contract_address: String,
|
||||
pub deposit_contract_deploy_block: u64,
|
||||
pub min_genesis_time: u64,
|
||||
}
|
||||
@@ -91,6 +92,16 @@ impl Eth2TestnetDir {
|
||||
min_genesis_time,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn deposit_contract_address(&self) -> Result<Address, String> {
|
||||
if self.deposit_contract_address.starts_with("0x") {
|
||||
self.deposit_contract_address[2..]
|
||||
.parse()
|
||||
.map_err(|e| format!("Corrupted address, unable to parse: {:?}", e))
|
||||
} else {
|
||||
Err("Corrupted address, must start with 0x".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user