Progress with account_manager deposit tools

This commit is contained in:
Paul Hauner
2019-11-25 09:33:11 +11:00
parent f3d02cf493
commit 4b15d4f433
7 changed files with 189 additions and 9 deletions

View File

@@ -12,3 +12,4 @@ tempdir = "0.3"
[dependencies]
serde = "1.0"
serde_json = "^1.0"
types = { path = "../../types"}

View File

@@ -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)]