mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Misc updates
This commit is contained in:
@@ -237,7 +237,9 @@ mod substrate {
|
||||
use scale::{Encode, Decode};
|
||||
use sp_runtime::{
|
||||
transaction_validity::*,
|
||||
traits::{Verify, ExtrinsicLike, ExtrinsicCall, Dispatchable, ValidateUnsigned, Checkable, Applyable},
|
||||
traits::{
|
||||
Verify, ExtrinsicLike, ExtrinsicCall, Dispatchable, ValidateUnsigned, Checkable, Applyable,
|
||||
},
|
||||
Weight,
|
||||
};
|
||||
#[rustfmt::skip]
|
||||
|
||||
@@ -43,7 +43,7 @@ bitcoin = { version = "0.32", optional = true }
|
||||
|
||||
ciphersuite = { path = "../../crypto/ciphersuite", optional = true }
|
||||
dalek-ff-group = { path = "../../crypto/dalek-ff-group", optional = true }
|
||||
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7f37cc8f770858aa1739e0f56dbe447db86f4ba6", version = "0.1.0", default-features = false, features = ["std"], optional = true }
|
||||
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", version = "0.1.0", default-features = false, features = ["std"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
rand_core = "0.6"
|
||||
|
||||
@@ -78,7 +78,7 @@ serai-env = { path = "../../common/env" }
|
||||
|
||||
curve25519-dalek = { version = "4", default-features = false, features = ["alloc", "zeroize"] }
|
||||
bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["std", "hazmat"] }
|
||||
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "7f37cc8f770858aa1739e0f56dbe447db86f4ba6", default-features = false, features = ["std"] }
|
||||
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "2c847f71079a105456376f9957cee86c4b6a9eb8", default-features = false, features = ["std"] }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -10,7 +10,10 @@ extern crate alloc;
|
||||
pub mod pallet {
|
||||
use sp_core::sr25519::Public;
|
||||
|
||||
use serai_abi::{primitives::{prelude::*, signals::*}, SubstrateBlock};
|
||||
use serai_abi::{
|
||||
primitives::{prelude::*, signals::*},
|
||||
SubstrateBlock,
|
||||
};
|
||||
|
||||
use frame_system::pallet_prelude::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
@@ -18,7 +21,9 @@ pub mod pallet {
|
||||
use validator_sets_pallet::{Config as VsConfig, Pallet as VsPallet};
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config<AccountId = Public, Block = SubstrateBlock> + VsConfig {
|
||||
pub trait Config:
|
||||
frame_system::Config<AccountId = Public, Block = SubstrateBlock> + VsConfig
|
||||
{
|
||||
/// How long a candidate retirement signal is valid for.
|
||||
///
|
||||
/// This MUST be equal to the rate at which new sets are attempted.
|
||||
@@ -297,8 +302,7 @@ pub mod pallet {
|
||||
retirement_signal: [u8; 32],
|
||||
) -> DispatchResult {
|
||||
let validator = ensure_signed(origin)?;
|
||||
let Some(registered_signal) = RegisteredRetirementSignals::<T>::get(retirement_signal)
|
||||
else {
|
||||
let Some(registered_signal) = RegisteredRetirementSignals::<T>::get(retirement_signal) else {
|
||||
return Err::<(), _>(Error::<T>::NonExistentRetirementSignal.into());
|
||||
};
|
||||
if SeraiAddress::from(validator) != registered_signal.registrant {
|
||||
@@ -325,11 +329,7 @@ pub mod pallet {
|
||||
/// Favor a signal.
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight((0, DispatchClass::Normal))] // TODO
|
||||
pub fn favor(
|
||||
origin: OriginFor<T>,
|
||||
signal: Signal,
|
||||
for_network: NetworkId,
|
||||
) -> DispatchResult {
|
||||
pub fn favor(origin: OriginFor<T>, signal: Signal, for_network: NetworkId) -> DispatchResult {
|
||||
let validator = ensure_signed(origin)?;
|
||||
|
||||
// Perform the relevant checks for this class of signal
|
||||
@@ -347,7 +347,7 @@ pub mod pallet {
|
||||
process.
|
||||
*/
|
||||
let Some(registered_signal) = RegisteredRetirementSignals::<T>::get(signal_id) else {
|
||||
return Err::<(), _>(Error::<T>::NonExistentRetirementSignal.into())
|
||||
return Err::<(), _>(Error::<T>::NonExistentRetirementSignal.into());
|
||||
};
|
||||
|
||||
// Check the signal isn't out of date, and its tallies with it.
|
||||
@@ -356,7 +356,7 @@ pub mod pallet {
|
||||
{
|
||||
Err::<(), _>(Error::<T>::ExpiredRetirementSignal)?;
|
||||
}
|
||||
},
|
||||
}
|
||||
Signal::Halt { .. } => {}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ pub mod pallet {
|
||||
Signal::Retire { signal_id } => {
|
||||
LockedInRetirement::<T>::set(Some((
|
||||
signal_id,
|
||||
frame_system::Pallet::<T>::block_number() + T::RetirementLockInDuration::get()
|
||||
frame_system::Pallet::<T>::block_number() + T::RetirementLockInDuration::get(),
|
||||
)));
|
||||
// TODO: Event
|
||||
}
|
||||
|
||||
@@ -95,7 +95,9 @@ mod pallet {
|
||||
use super::*;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config + coins_pallet::Config<coins_pallet::CoinsInstance> {
|
||||
pub trait Config:
|
||||
frame_system::Config + coins_pallet::Config<coins_pallet::CoinsInstance>
|
||||
{
|
||||
// type ShouldEndSession: ShouldEndSession<BlockNumberFor<Self>>;
|
||||
}
|
||||
|
||||
@@ -846,7 +848,11 @@ mod pallet {
|
||||
#[pallet::weight((0, DispatchClass::Normal))] // TODO
|
||||
pub fn allocate(origin: OriginFor<T>, network: NetworkId, amount: Amount) -> DispatchResult {
|
||||
let validator = ensure_signed(origin)?;
|
||||
Coins::<T, coins_pallet::CoinsInstance>::transfer_fn(validator, Self::account(), Balance { coin: Coin::Serai, amount })?;
|
||||
Coins::<T, coins_pallet::CoinsInstance>::transfer_fn(
|
||||
validator,
|
||||
Self::account(),
|
||||
Balance { coin: Coin::Serai, amount },
|
||||
)?;
|
||||
Abstractions::<T>::increase_allocation(network, validator, amount, false)
|
||||
.map_err(Error::<T>::AllocationError)?;
|
||||
Ok(())
|
||||
@@ -860,7 +866,11 @@ mod pallet {
|
||||
let deallocation_timeline = Abstractions::<T>::decrease_allocation(network, account, amount)
|
||||
.map_err(Error::<T>::DeallocationError)?;
|
||||
if matches!(deallocation_timeline, DeallocationTimeline::Immediate) {
|
||||
Coins::<T, coins_pallet::CoinsInstance>::transfer_fn(Self::account(), account, Balance { coin: Coin::Serai, amount })?;
|
||||
Coins::<T, coins_pallet::CoinsInstance>::transfer_fn(
|
||||
Self::account(),
|
||||
account,
|
||||
Balance { coin: Coin::Serai, amount },
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -876,7 +886,11 @@ mod pallet {
|
||||
let account = ensure_signed(origin)?;
|
||||
let amount = Abstractions::<T>::claim_delayed_deallocation(account, network, session)
|
||||
.map_err(Error::<T>::DeallocationError)?;
|
||||
Coins::<T, coins_pallet::CoinsInstance>::transfer_fn(Self::account(), account, Balance { coin: Coin::Serai, amount })?;
|
||||
Coins::<T, coins_pallet::CoinsInstance>::transfer_fn(
|
||||
Self::account(),
|
||||
account,
|
||||
Balance { coin: Coin::Serai, amount },
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user