Directory Restructure (#1163)

* Move tests -> testing

* Directory restructure

* Update Cargo.toml during restructure

* Update Makefile during restructure

* Fix arbitrary path
This commit is contained in:
Paul Hauner
2020-05-18 21:24:23 +10:00
committed by GitHub
parent c571afb8d8
commit 4331834003
358 changed files with 217 additions and 229 deletions

View File

@@ -0,0 +1,65 @@
use serde::{Deserialize, Serialize};
use serde_repr::*;
use std::convert::TryFrom;
pub use eth2_keystore::json_keystore::{
Aes128Ctr, ChecksumModule, Cipher, CipherModule, Crypto, EmptyMap, EmptyString, Kdf, KdfModule,
Scrypt, Sha256Checksum,
};
pub use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct JsonWallet {
pub crypto: Crypto,
pub name: String,
// TODO: confirm if this field is optional or not.
//
// Reference:
//
// https://github.com/sigp/lighthouse/pull/1117#discussion_r422892396
pub nextaccount: u32,
pub uuid: Uuid,
pub version: Version,
#[serde(rename = "type")]
pub type_field: TypeField,
}
/// Version for `JsonWallet`.
#[derive(Debug, Clone, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum Version {
V1 = 1,
}
impl Version {
pub fn one() -> Self {
Version::V1
}
}
/// Used for ensuring that serde only decodes valid checksum functions.
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[serde(try_from = "String", into = "String")]
pub enum TypeField {
Hd,
}
impl Into<String> for TypeField {
fn into(self) -> String {
match self {
TypeField::Hd => "hierarchical deterministic".into(),
}
}
}
impl TryFrom<String> for TypeField {
type Error = String;
fn try_from(s: String) -> Result<Self, Self::Error> {
match s.as_ref() {
"hierarchical deterministic" => Ok(TypeField::Hd),
other => Err(format!("Unsupported type function: {}", other)),
}
}
}