mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 04:09:23 +00:00
Use an enum for Coin/NetworkId
It originally wasn't an enum so software which had yet to update before an integration wouldn't error (as now enums are strictly typed). The strict typing is preferable though.
This commit is contained in:
@@ -24,6 +24,8 @@ transcript = { package = "flexible-transcript", path = "../crypto/transcript", f
|
||||
ciphersuite = { path = "../crypto/ciphersuite" }
|
||||
frost = { package = "modular-frost", path = "../crypto/frost" }
|
||||
|
||||
scale = { package = "parity-scale-codec", version = "3", features = ["derive"] }
|
||||
|
||||
serai-db = { path = "../common/db" }
|
||||
|
||||
processor-messages = { package = "processor-messages", path = "../processor/messages" }
|
||||
|
||||
@@ -177,18 +177,7 @@ async fn handle_batch_and_burns<D: Db, Pro: Processor>(
|
||||
|
||||
for burn in serai.get_burn_events(hash).await? {
|
||||
if let TokensEvent::Burn { address: _, balance, instruction } = burn {
|
||||
// TODO: Move Network/Coin to an enum and provide this mapping
|
||||
let network = {
|
||||
use serai_client::primitives::*;
|
||||
match balance.coin {
|
||||
BITCOIN => BITCOIN_NET_ID,
|
||||
ETHER => ETHEREUM_NET_ID,
|
||||
DAI => ETHEREUM_NET_ID,
|
||||
MONERO => MONERO_NET_ID,
|
||||
invalid => panic!("burn from unrecognized coin: {invalid:?}"),
|
||||
}
|
||||
};
|
||||
|
||||
let network = balance.coin.network();
|
||||
network_had_event(&mut burns, network);
|
||||
|
||||
// network_had_event should register an entry in burns
|
||||
|
||||
@@ -5,6 +5,8 @@ use transcript::{Transcript, RecommendedTranscript};
|
||||
|
||||
use frost::Participant;
|
||||
|
||||
use scale::Encode;
|
||||
|
||||
use serai_client::validator_sets::primitives::ValidatorSet;
|
||||
|
||||
#[rustfmt::skip]
|
||||
@@ -18,7 +20,7 @@ pub fn genesis(serai_block: [u8; 32], set: ValidatorSet) -> [u8; 32] {
|
||||
// This locks it to a specific Serai chain
|
||||
genesis.append_message(b"serai_block", serai_block);
|
||||
genesis.append_message(b"session", set.session.0.to_le_bytes());
|
||||
genesis.append_message(b"network", set.network.0.to_le_bytes());
|
||||
genesis.append_message(b"network", set.network.encode());
|
||||
let genesis = genesis.challenge(b"genesis");
|
||||
let genesis_ref: &[u8] = genesis.as_ref();
|
||||
genesis_ref[.. 32].try_into().unwrap()
|
||||
|
||||
Reference in New Issue
Block a user