Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 25c51e5

Browse files
committed
Add TryFrom<u8>
1 parent 7df4f78 commit 25c51e5

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

crates/op-test-vectors/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ alloy-consensus.workspace = true
2525
op-alloy-rpc-types.workspace = true
2626
op-alloy-consensus.workspace = true
2727

28+
# Kona
29+
kona-primitives.workspace = true
30+
2831
[dev-dependencies]
2932
serde_json.workspace = true
30-
kona-primitives.workspace = true

crates/op-test-vectors/src/faultproof.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use alloy_primitives::{BlockHash, BlockNumber, Bytes, B256};
44
use hashbrown::HashMap;
5-
use kona_derive::types::RollupConfig;
5+
use kona_primitives::RollupConfig;
66
use serde::{Deserialize, Serialize};
77
use serde_repr::{Deserialize_repr, Serialize_repr};
88

@@ -54,9 +54,29 @@ pub enum FaultProofStatus {
5454
Unknown,
5555
}
5656

57+
impl TryFrom<u8> for FaultProofStatus {
58+
type Error = String;
59+
60+
fn try_from(value: u8) -> Result<Self, Self::Error> {
61+
match value {
62+
0 => Ok(FaultProofStatus::Valid),
63+
1 => Ok(FaultProofStatus::Invalid),
64+
2 => Ok(FaultProofStatus::Panic),
65+
3 => Ok(FaultProofStatus::Unfinished),
66+
_ => Ok(FaultProofStatus::Unknown),
67+
}
68+
}
69+
}
70+
71+
impl From<FaultProofStatus> for u8 {
72+
fn from(status: FaultProofStatus) -> u8 {
73+
status as u8
74+
}
75+
}
76+
5777
#[cfg(test)]
5878
mod tests {
59-
use kona_derive::types::BASE_MAINNET_CONFIG;
79+
use kona_primitives::BASE_MAINNET_CONFIG;
6080

6181
use super::*;
6282

0 commit comments

Comments
 (0)