-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #800 from h4sh3d/feat/config-swap-finality
Config: expose swap finality parameters
- Loading branch information
Showing
14 changed files
with
508 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
//! This module defines the currently supported blockchains in the node for the arbitrating and | ||
//! the accordant roles. The types defined here are convertible with core `Blockchain` type. | ||
use std::convert::TryFrom; | ||
use std::str::FromStr; | ||
|
||
use farcaster_core::{blockchain::Blockchain, consensus}; | ||
use strict_encoding::{StrictDecode, StrictEncode}; | ||
|
||
/// A list of supported arbitrating blockchain | ||
#[derive( | ||
Debug, | ||
Clone, | ||
Copy, | ||
Hash, | ||
PartialEq, | ||
Eq, | ||
Parser, | ||
Display, | ||
Serialize, | ||
Deserialize, | ||
StrictEncode, | ||
StrictDecode, | ||
)] | ||
#[serde(crate = "serde_crate")] | ||
#[display(Debug)] | ||
pub enum ArbitratingBlockchain { | ||
/// The Bitcoin (BTC) blockchain. | ||
Bitcoin, | ||
} | ||
|
||
impl FromStr for ArbitratingBlockchain { | ||
type Err = consensus::Error; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"Bitcoin" | "bitcoin" | "btc" | "BTC" => Ok(ArbitratingBlockchain::Bitcoin), | ||
_ => Err(consensus::Error::UnknownType), | ||
} | ||
} | ||
} | ||
|
||
impl Into<Blockchain> for ArbitratingBlockchain { | ||
fn into(self) -> Blockchain { | ||
match self { | ||
ArbitratingBlockchain::Bitcoin => Blockchain::Bitcoin, | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<Blockchain> for ArbitratingBlockchain { | ||
type Error = consensus::Error; | ||
|
||
fn try_from(blockchain: Blockchain) -> Result<Self, Self::Error> { | ||
match blockchain { | ||
Blockchain::Bitcoin => Ok(ArbitratingBlockchain::Bitcoin), | ||
_ => Err(consensus::Error::TypeMismatch), | ||
} | ||
} | ||
} | ||
|
||
/// A list of supported accordant blockchain | ||
#[derive( | ||
Debug, | ||
Clone, | ||
Copy, | ||
Hash, | ||
PartialEq, | ||
Eq, | ||
Parser, | ||
Display, | ||
Serialize, | ||
Deserialize, | ||
StrictEncode, | ||
StrictDecode, | ||
)] | ||
#[serde(crate = "serde_crate")] | ||
#[display(Debug)] | ||
pub enum AccordantBlockchain { | ||
/// The Monero (XMR) blockchain. | ||
Monero, | ||
// NOTE: we could in theory add Bitcoin here, but currently the node does not support it | ||
} | ||
|
||
impl FromStr for AccordantBlockchain { | ||
type Err = consensus::Error; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"Monero" | "monero" | "xmr" | "XMR" => Ok(AccordantBlockchain::Monero), | ||
_ => Err(consensus::Error::UnknownType), | ||
} | ||
} | ||
} | ||
|
||
impl Into<Blockchain> for AccordantBlockchain { | ||
fn into(self) -> Blockchain { | ||
match self { | ||
AccordantBlockchain::Monero => Blockchain::Monero, | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<Blockchain> for AccordantBlockchain { | ||
type Error = consensus::Error; | ||
|
||
fn try_from(blockchain: Blockchain) -> Result<Self, Self::Error> { | ||
match blockchain { | ||
Blockchain::Monero => Ok(AccordantBlockchain::Monero), | ||
_ => Err(consensus::Error::TypeMismatch), | ||
} | ||
} | ||
} |
Oops, something went wrong.