mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +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:
@@ -37,7 +37,7 @@ use bitcoin_serai::bitcoin::{
|
||||
};
|
||||
|
||||
use serai_client::{
|
||||
primitives::{MAX_DATA_LEN, BITCOIN, BITCOIN_NET_ID, NetworkId, Amount, Balance},
|
||||
primitives::{MAX_DATA_LEN, Coin as SeraiCoin, NetworkId, Amount, Balance},
|
||||
coins::bitcoin::Address,
|
||||
};
|
||||
|
||||
@@ -97,7 +97,7 @@ impl OutputTrait for Output {
|
||||
}
|
||||
|
||||
fn balance(&self) -> Balance {
|
||||
Balance { coin: BITCOIN, amount: Amount(self.output.value()) }
|
||||
Balance { coin: SeraiCoin::Bitcoin, amount: Amount(self.output.value()) }
|
||||
}
|
||||
|
||||
fn data(&self) -> &[u8] {
|
||||
@@ -293,7 +293,7 @@ impl Coin for Bitcoin {
|
||||
|
||||
type Address = Address;
|
||||
|
||||
const NETWORK: NetworkId = BITCOIN_NET_ID;
|
||||
const NETWORK: NetworkId = NetworkId::Bitcoin;
|
||||
const ID: &'static str = "Bitcoin";
|
||||
const CONFIRMATIONS: usize = 6;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ use monero_serai::{
|
||||
use tokio::time::sleep;
|
||||
|
||||
pub use serai_client::{
|
||||
primitives::{MAX_DATA_LEN, MONERO, MONERO_NET_ID, NetworkId, Amount, Balance},
|
||||
primitives::{MAX_DATA_LEN, Coin as SeraiCoin, NetworkId, Amount, Balance},
|
||||
coins::monero::Address,
|
||||
};
|
||||
|
||||
@@ -66,7 +66,7 @@ impl OutputTrait for Output {
|
||||
}
|
||||
|
||||
fn balance(&self) -> Balance {
|
||||
Balance { coin: MONERO, amount: Amount(self.0.commitment().amount) }
|
||||
Balance { coin: SeraiCoin::Monero, amount: Amount(self.0.commitment().amount) }
|
||||
}
|
||||
|
||||
fn data(&self) -> &[u8] {
|
||||
@@ -221,7 +221,7 @@ impl Coin for Monero {
|
||||
|
||||
type Address = Address;
|
||||
|
||||
const NETWORK: NetworkId = MONERO_NET_ID;
|
||||
const NETWORK: NetworkId = NetworkId::Monero;
|
||||
const ID: &'static str = "Monero";
|
||||
const CONFIRMATIONS: usize = 10;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ use serai_db::{DbTxn, Db, MemDb};
|
||||
|
||||
use sp_application_crypto::sr25519;
|
||||
use serai_client::{
|
||||
primitives::{MONERO_NET_ID, BlockHash},
|
||||
primitives::{BlockHash, NetworkId},
|
||||
validator_sets::primitives::{Session, ValidatorSet},
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::{
|
||||
};
|
||||
|
||||
const ID: KeyGenId =
|
||||
KeyGenId { set: ValidatorSet { session: Session(1), network: MONERO_NET_ID }, attempt: 3 };
|
||||
KeyGenId { set: ValidatorSet { session: Session(1), network: NetworkId::Monero }, attempt: 3 };
|
||||
|
||||
pub async fn test_key_gen<C: Coin>() {
|
||||
let mut entropies = HashMap::new();
|
||||
|
||||
@@ -30,20 +30,20 @@ async fn test_substrate_signer() {
|
||||
SignId { key: keys[&participant_one].group_key().to_bytes().to_vec(), id: block.0, attempt: 0 };
|
||||
|
||||
let batch = Batch {
|
||||
network: MONERO_NET_ID,
|
||||
network: NetworkId::Monero,
|
||||
id: 5,
|
||||
block,
|
||||
instructions: vec![
|
||||
InInstructionWithBalance {
|
||||
instruction: InInstruction::Transfer(SeraiAddress([0xbb; 32])),
|
||||
balance: Balance { coin: BITCOIN, amount: Amount(1000) },
|
||||
balance: Balance { coin: Coin::Bitcoin, amount: Amount(1000) },
|
||||
},
|
||||
InInstructionWithBalance {
|
||||
instruction: InInstruction::Call(ApplicationCall {
|
||||
application: Application::DEX,
|
||||
data: Data::new(vec![0xcc; 128]).unwrap(),
|
||||
}),
|
||||
balance: Balance { coin: MONERO, amount: Amount(9999999999999999) },
|
||||
balance: Balance { coin: Coin::Monero, amount: Amount(9999999999999999) },
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user