mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 04:09:23 +00:00
Define an array of all NetworkIds in serai_primitives
This commit is contained in:
@@ -3,7 +3,7 @@ use rand_core::{RngCore, OsRng};
|
||||
use sp_core::{sr25519::Public, Pair};
|
||||
|
||||
use serai_client::{
|
||||
primitives::{NetworkId, insecure_pair_from_name},
|
||||
primitives::{NETWORKS, NetworkId, insecure_pair_from_name},
|
||||
validator_sets::{
|
||||
primitives::{Session, ValidatorSet, musig_key},
|
||||
ValidatorSetsEvent,
|
||||
@@ -38,7 +38,7 @@ serai_test!(
|
||||
.get_new_set_events(serai.get_block_by_number(0).await.unwrap().unwrap().hash())
|
||||
.await
|
||||
.unwrap(),
|
||||
[NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero]
|
||||
NETWORKS
|
||||
.iter()
|
||||
.copied()
|
||||
.map(|network| ValidatorSetsEvent::NewSet {
|
||||
|
||||
@@ -56,8 +56,7 @@ fn testnet_genesis(
|
||||
|
||||
validator_sets: ValidatorSetsConfig {
|
||||
stake: Amount(1_000_000 * 10_u64.pow(8)),
|
||||
// TODO: Array of these in primitives
|
||||
networks: vec![NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero],
|
||||
networks: serai_runtime::primitives::NETWORKS.to_vec(),
|
||||
participants: validators.iter().map(|name| account_from_name(name)).collect(),
|
||||
},
|
||||
session: SessionConfig { keys: validators.iter().map(|name| session_key(*name)).collect() },
|
||||
|
||||
@@ -31,6 +31,9 @@ pub enum NetworkId {
|
||||
Monero,
|
||||
}
|
||||
|
||||
pub const NETWORKS: [NetworkId; 4] =
|
||||
[NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero];
|
||||
|
||||
/// The type used to identify coins.
|
||||
#[derive(
|
||||
Clone,
|
||||
|
||||
@@ -32,7 +32,7 @@ pub mod pallet {
|
||||
///
|
||||
/// Every participant at genesis will automatically be assumed to have this much stake.
|
||||
/// This stake cannot be withdrawn however as there's no actual stake behind it.
|
||||
// TODO: Localize stake to network?
|
||||
// TODO: Localize stake to network
|
||||
pub stake: Amount,
|
||||
/// Networks to spawn Serai with.
|
||||
pub networks: Vec<NetworkId>,
|
||||
@@ -572,9 +572,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
pub fn new_session() {
|
||||
// TODO: Define an array of all networks in primitives
|
||||
let networks = [NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero];
|
||||
for network in networks {
|
||||
for network in serai_primitives::NETWORKS {
|
||||
let current_session = Self::session(network);
|
||||
// Only spawn a NewSet if the current set was actually established with a completed
|
||||
// handover protocol
|
||||
|
||||
Reference in New Issue
Block a user