Skip to content

Commit

Permalink
Add NetworkType::Preview
Browse files Browse the repository at this point in the history
Signed-off-by: Eval EXEC <[email protected]>
  • Loading branch information
eval-exec committed Sep 6, 2024
1 parent e01d193 commit 7b13c2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub const PREFIX_TESTNET: &str = "ckt";
pub const NETWORK_MAINNET: &str = "ckb";
pub const NETWORK_TESTNET: &str = "ckb_testnet";
pub const NETWORK_STAGING: &str = "ckb_staging";
pub const NETWORK_PREVIEW: &str = "ckb_preview";
pub const NETWORK_DEV: &str = "ckb_dev";

pub const SECP_SIGNATURE_SIZE: usize = 65;
Expand Down
7 changes: 6 additions & 1 deletion src/types/network_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ use std::fmt;
use serde_derive::{Deserialize, Serialize};

use crate::constants::{
NETWORK_DEV, NETWORK_MAINNET, NETWORK_STAGING, NETWORK_TESTNET, PREFIX_MAINNET, PREFIX_TESTNET,
NETWORK_DEV, NETWORK_MAINNET, NETWORK_STAGING, NETWORK_TESTNET,NETWORK_PREVIEW, PREFIX_MAINNET, PREFIX_TESTNET,
};

#[derive(Hash, Eq, PartialEq, Debug, Clone, Copy, Serialize, Deserialize)]
pub enum NetworkType {
Mainnet,
Testnet,
Staging,
Preview,
Dev,
}

Expand All @@ -28,6 +29,7 @@ impl NetworkType {
NetworkType::Mainnet => PREFIX_MAINNET,
NetworkType::Testnet => PREFIX_TESTNET,
NetworkType::Staging => PREFIX_TESTNET,
NetworkType::Preview => PREFIX_TESTNET,
NetworkType::Dev => PREFIX_TESTNET,
}
}
Expand All @@ -37,6 +39,7 @@ impl NetworkType {
NETWORK_MAINNET => Some(NetworkType::Mainnet),
NETWORK_TESTNET => Some(NetworkType::Testnet),
NETWORK_STAGING => Some(NetworkType::Staging),
NETWORK_PREVIEW => Some(NetworkType::Preview),
NETWORK_DEV => Some(NetworkType::Dev),
_ => None,
}
Expand All @@ -47,6 +50,7 @@ impl NetworkType {
NetworkType::Mainnet => NETWORK_MAINNET,
NetworkType::Testnet => NETWORK_TESTNET,
NetworkType::Staging => NETWORK_STAGING,
NetworkType::Preview => NETWORK_PREVIEW,
NetworkType::Dev => NETWORK_DEV,
}
}
Expand All @@ -73,6 +77,7 @@ impl NetworkInfo {
NetworkType::Mainnet => Some(Self::mainnet()),
NetworkType::Testnet => Some(Self::testnet()),
NetworkType::Staging => None,
NetworkType::Preview => None,
NetworkType::Dev => None,
}
}
Expand Down

0 comments on commit 7b13c2e

Please sign in to comment.