From d833254b842c0feb1f0d5f19ee7e8fce61dda0a6 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 19 Oct 2023 07:16:35 -0400 Subject: [PATCH] Other clippy fixes --- substrate/coins/pallet/src/lib.rs | 31 ++++++----------------------- tests/coordinator/src/tests/sign.rs | 4 ++-- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/substrate/coins/pallet/src/lib.rs b/substrate/coins/pallet/src/lib.rs index d0db757b..b1bf738c 100644 --- a/substrate/coins/pallet/src/lib.rs +++ b/substrate/coins/pallet/src/lib.rs @@ -59,15 +59,8 @@ pub mod pallet { // ID. #[pallet::storage] #[pallet::getter(fn balances)] - pub type Balances = StorageDoubleMap< - _, - Blake2_128Concat, - Public, - Identity, - Coin, - SubstrateAmount, - ValueQuery, - >; + pub type Balances = + StorageDoubleMap<_, Blake2_128Concat, Public, Identity, Coin, SubstrateAmount, ValueQuery>; /// The total supply of each coin. // We use Identity type here again due to reasons stated in the Balances Storage. @@ -158,10 +151,7 @@ pub mod pallet { } // Burn `balance` from the specified account. - fn burn_internal( - from: Public, - balance: Balance, - ) -> Result<(), Error> { + fn burn_internal(from: Public, balance: Balance) -> Result<(), Error> { // don't waste time if amount == 0 if balance.amount.0 == 0 { return Ok(()); @@ -171,18 +161,13 @@ pub mod pallet { Self::decrease_balance_internal(from, balance)?; // update the supply - let new_supply = Self::supply(balance.coin) - .checked_sub(balance.amount.0) - .unwrap(); + let new_supply = Self::supply(balance.coin).checked_sub(balance.amount.0).unwrap(); Supply::::set(balance.coin, new_supply); Ok(()) } - pub fn burn_sri( - from: Public, - amount: Amount, - ) -> Result<(), Error> { + pub fn burn_sri(from: Public, amount: Amount) -> Result<(), Error> { Self::burn_internal(from, Balance { coin: Coin::Serai, amount })?; Self::deposit_event(Event::SriBurn { from, amount }); Ok(()) @@ -201,11 +186,7 @@ pub mod pallet { } /// Transfer `balance` from `from` to `to`. - pub fn transfer_internal( - from: Public, - to: Public, - balance: Balance, - ) -> Result<(), Error> { + pub fn transfer_internal(from: Public, to: Public, balance: Balance) -> Result<(), Error> { // update balances of accounts Self::decrease_balance_internal(from, balance)?; Self::increase_balance_internal(to, balance)?; diff --git a/tests/coordinator/src/tests/sign.rs b/tests/coordinator/src/tests/sign.rs index 3f9c26be..716de174 100644 --- a/tests/coordinator/src/tests/sign.rs +++ b/tests/coordinator/src/tests/sign.rs @@ -258,7 +258,7 @@ async fn sign_test() { // Verify the mint occurred as expected assert_eq!( serai.mint_events().await.unwrap(), - vec![CoinsEvent::Mint { address: serai_addr, balance }] + vec![CoinsEvent::Mint { to: serai_addr.into(), balance }] ); assert_eq!(serai.coin_supply(Coin::Bitcoin).await.unwrap(), amount); assert_eq!(serai.coin_balance(Coin::Bitcoin, serai_addr).await.unwrap(), amount); @@ -301,7 +301,7 @@ async fn sign_test() { assert_eq!(burn_events.len(), 1); assert_eq!( burn_events[0], - CoinsEvent::Burn { address: serai_addr, instruction: out_instruction.clone() } + CoinsEvent::Burn { from: serai_addr.into(), instruction: out_instruction.clone() } ); break 'outer; }