Skip to content

Commit 1e37af6

Browse files
committed
Move Cardano chain adpater to submodule
1 parent 0e834d9 commit 1e37af6

File tree

4 files changed

+7
-34
lines changed

4 files changed

+7
-34
lines changed

mithril-common/src/era/cardano_chain_adapter.rs renamed to mithril-common/src/era/adapters/cardano_chain.rs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
key_decode_hex, EraMarkersSigner, EraMarkersVerifier, EraMarkersVerifierSignature,
55
EraMarkersVerifierVerificationKey,
66
},
7-
entities::Epoch,
7+
era::{EraMarker, EraReaderAdapter},
88
};
99
use async_trait::async_trait;
1010
use hex::{FromHex, ToHex};
@@ -15,35 +15,6 @@ use thiserror::Error;
1515

1616
type GeneralError = Box<dyn StdError + Sync + Send>;
1717

18-
// TODO: remove EraMarker & EraReaderAdapter w/ they are available
19-
20-
/// Value object that represents a tag of Era change.
21-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
22-
pub struct EraMarker {
23-
/// Era name
24-
pub name: String,
25-
26-
/// Eventual information that advertises the Epoch of transition.
27-
pub epoch: Option<Epoch>,
28-
}
29-
30-
impl EraMarker {
31-
/// instanciate a new [EraMarker].
32-
pub fn new(name: &str, epoch: Option<Epoch>) -> Self {
33-
let name = name.to_string();
34-
35-
Self { name, epoch }
36-
}
37-
}
38-
39-
#[async_trait]
40-
pub trait EraReaderAdapter: Sync + Send {
41-
/// Read era markers from the underlying adapter.
42-
async fn read(&self) -> Result<Vec<EraMarker>, GeneralError>;
43-
}
44-
45-
// TODO: Keep Cardano Chain Adapter part below
46-
4718
type HexEncodeEraMarkerSignature = String;
4819

4920
/// [EraMarkersPayload] related errors.
@@ -158,6 +129,7 @@ impl EraReaderAdapter for CardanoChainAdapter {
158129
mod test {
159130
use crate::chain_observer::{FakeObserver, TxDatum};
160131
use crate::crypto_helper::{key_encode_hex, EraMarkersSigner};
132+
use crate::entities::Epoch;
161133

162134
use super::*;
163135

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Module dedicated to EraReaderAdapter implementations.
22
mod bootstrap;
3+
mod cardano_chain;
34
mod dummy;
45

56
pub use bootstrap::BootstrapAdapter as EraReaderBootstrapAdapter;
7+
pub use cardano_chain::CardanoChainAdapter;
68
pub use dummy::DummyAdapter as EraReaderDummyAdapter;

mithril-common/src/era/era_reader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
use std::{error::Error as StdError, str::FromStr};
2-
31
use crate::entities::Epoch;
42
use async_trait::async_trait;
3+
use serde::{Deserialize, Serialize};
4+
use std::{error::Error as StdError, str::FromStr};
55
use thiserror::Error;
66

77
use super::{supported_era::UnsupportedEraError, SupportedEra};
88

99
/// Value object that represents a tag of Era change.
10-
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
1111
pub struct EraMarker {
1212
/// Era name
1313
pub name: String,

mithril-common/src/era/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! The module used for handling eras
22
33
pub mod adapters;
4-
mod cardano_chain_adapter;
54
mod era_checker;
65
mod era_reader;
76
mod supported_era;

0 commit comments

Comments
 (0)