mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
cargo fmt
This commit is contained in:
@@ -60,15 +60,8 @@ pub mod pallet {
|
|||||||
// ID.
|
// ID.
|
||||||
#[pallet::storage]
|
#[pallet::storage]
|
||||||
#[pallet::getter(fn balances)]
|
#[pallet::getter(fn balances)]
|
||||||
pub type Balances<T: Config> = StorageDoubleMap<
|
pub type Balances<T: Config> =
|
||||||
_,
|
StorageDoubleMap<_, Blake2_128Concat, Public, Identity, Coin, SubstrateAmount, ValueQuery>;
|
||||||
Blake2_128Concat,
|
|
||||||
Public,
|
|
||||||
Identity,
|
|
||||||
Coin,
|
|
||||||
SubstrateAmount,
|
|
||||||
ValueQuery,
|
|
||||||
>;
|
|
||||||
|
|
||||||
/// The total supply of each coin.
|
/// The total supply of each coin.
|
||||||
// We use Identity type here again due to reasons stated in the Balances Storage.
|
// We use Identity type here again due to reasons stated in the Balances Storage.
|
||||||
@@ -159,10 +152,7 @@ pub mod pallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Burn `balance` from the specified account.
|
// Burn `balance` from the specified account.
|
||||||
fn burn_internal(
|
fn burn_internal(from: Public, balance: Balance) -> Result<(), Error<T>> {
|
||||||
from: Public,
|
|
||||||
balance: Balance,
|
|
||||||
) -> Result<(), Error<T>> {
|
|
||||||
// don't waste time if amount == 0
|
// don't waste time if amount == 0
|
||||||
if balance.amount.0 == 0 {
|
if balance.amount.0 == 0 {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -172,18 +162,13 @@ pub mod pallet {
|
|||||||
Self::decrease_balance_internal(from, balance)?;
|
Self::decrease_balance_internal(from, balance)?;
|
||||||
|
|
||||||
// update the supply
|
// update the supply
|
||||||
let new_supply = Self::supply(balance.coin)
|
let new_supply = Self::supply(balance.coin).checked_sub(balance.amount.0).unwrap();
|
||||||
.checked_sub(balance.amount.0)
|
|
||||||
.unwrap();
|
|
||||||
Supply::<T>::set(balance.coin, new_supply);
|
Supply::<T>::set(balance.coin, new_supply);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn burn_sri(
|
pub fn burn_sri(from: Public, amount: Amount) -> Result<(), Error<T>> {
|
||||||
from: Public,
|
|
||||||
amount: Amount,
|
|
||||||
) -> Result<(), Error<T>> {
|
|
||||||
Self::burn_internal(from, Balance { coin: Coin::Serai, amount })?;
|
Self::burn_internal(from, Balance { coin: Coin::Serai, amount })?;
|
||||||
Self::deposit_event(Event::SriBurn { from, amount });
|
Self::deposit_event(Event::SriBurn { from, amount });
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -202,11 +187,7 @@ pub mod pallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Transfer `balance` from `from` to `to`.
|
/// Transfer `balance` from `from` to `to`.
|
||||||
pub fn transfer_internal(
|
pub fn transfer_internal(from: Public, to: Public, balance: Balance) -> Result<(), Error<T>> {
|
||||||
from: Public,
|
|
||||||
to: Public,
|
|
||||||
balance: Balance,
|
|
||||||
) -> Result<(), Error<T>> {
|
|
||||||
// update balances of accounts
|
// update balances of accounts
|
||||||
Self::decrease_balance_internal(from, balance)?;
|
Self::decrease_balance_internal(from, balance)?;
|
||||||
Self::increase_balance_internal(to, balance)?;
|
Self::increase_balance_internal(to, balance)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user