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 12, 2024
1 parent e01d193 commit 9e78657
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
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
3 changes: 2 additions & 1 deletion src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ impl Context {
/// Run all scripts in the transaction in ckb-vm
pub fn verify_scripts(&self, tx: TransactionView) -> Result<Cycle, Error> {
let mock_tx = self.to_mock_tx(tx.data());
let resource = Resource::from_both(&mock_tx, &mut DummyLoader).map_err(Error::VerifyScript)?;
let resource =
Resource::from_both(&mock_tx, &mut DummyLoader).map_err(Error::VerifyScript)?;
let rtx = resolve_transaction(tx, &mut HashSet::new(), &resource, &resource)
.map_err(|err| Error::VerifyScript(format!("Resolve transaction error: {:?}", err)))?;
let consensus = ConsensusBuilder::default()
Expand Down
8 changes: 7 additions & 1 deletion src/types/network_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ 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_PREVIEW, NETWORK_STAGING, NETWORK_TESTNET,
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 +30,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 +40,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 +51,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 +78,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 9e78657

Please sign in to comment.