Skip to content

Commit dccf0d5

Browse files
committed
format
1 parent 04488d2 commit dccf0d5

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

substrate/frame/assets/precompiles/src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use frame_support::traits::fungibles::{
3030
approvals::Inspect as ApprovalsInspect, metadata::Inspect as MetadataInspect,
3131
};
3232
use pallet_assets::{weights::WeightInfo as _, Call, Config, TransferFlags};
33-
use sp_runtime::traits::{Bounded, UniqueSaturatedInto, Zero};
3433
use pallet_revive::precompiles::{
3534
alloy::{
3635
self,
@@ -39,6 +38,7 @@ use pallet_revive::precompiles::{
3938
},
4039
AddressMapper, AddressMatcher, Error, Ext, Precompile, RuntimeCosts, H160, H256,
4140
};
41+
use sp_runtime::traits::{Bounded, UniqueSaturatedInto, Zero};
4242
use weights::WeightInfo as _;
4343

4444
pub mod foreign_assets;
@@ -489,18 +489,14 @@ where
489489
// fungibles trait. This pins the sentinel invariant to storage state —
490490
// "an approval row exists and its amount is `Balance::MAX`" — rather
491491
// than to a trait return value that a future impl could synthesise.
492-
let approval = pallet_assets::Approvals::<Runtime, Instance>::get((
493-
asset_id.clone(),
494-
&from,
495-
&spender,
496-
));
492+
let approval =
493+
pallet_assets::Approvals::<Runtime, Instance>::get((asset_id.clone(), &from, &spender));
497494
let actual_weight = match approval {
498495
Some(a) if a.amount == <Runtime as Config<Instance>>::Balance::max_value() => {
499496
// Sentinel: bypass `do_transfer_approved` so the approval is not
500497
// decremented. The match arm itself confirms an approval row
501498
// exists; `do_transfer` enforces the balance check.
502-
let f =
503-
TransferFlags { keep_alive: false, best_effort: false, burn_dust: false };
499+
let f = TransferFlags { keep_alive: false, best_effort: false, burn_dust: false };
504500
pallet_assets::Pallet::<Runtime, Instance>::do_transfer(
505501
asset_id,
506502
&from,

substrate/frame/assets/precompiles/src/tests.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ fn transfer_from_reverts_with_unapproved_when_no_allowance() {
350350
Balances::make_free_balance_be(&recipient, 100);
351351

352352
let owner_addr = <Test as pallet_revive::Config>::AddressMapper::to_address(&owner);
353-
let recipient_addr =
354-
<Test as pallet_revive::Config>::AddressMapper::to_address(&recipient);
353+
let recipient_addr = <Test as pallet_revive::Config>::AddressMapper::to_address(&recipient);
355354

356355
assert_ok!(Assets::force_create(RuntimeOrigin::root(), asset_id, owner, true, 1));
357356
assert_ok!(Assets::mint(RuntimeOrigin::signed(owner), asset_id, owner, 100));
@@ -379,10 +378,7 @@ fn transfer_from_reverts_with_unapproved_when_no_allowance() {
379378
// which surfaces as a trap (Module error), not a Solidity-style revert.
380379
// Either path means the call failed; pin that it carries the right reason.
381380
let err = result.expect_err("transferFrom must fail with no allowance");
382-
assert!(
383-
format!("{err:?}").contains("Unapproved"),
384-
"unexpected failure reason: {err:?}",
385-
);
381+
assert!(format!("{err:?}").contains("Unapproved"), "unexpected failure reason: {err:?}",);
386382

387383
// Balances unchanged.
388384
assert_eq!(Assets::balance(asset_id, &owner), 100);

0 commit comments

Comments
 (0)