Skip to content

Commit

Permalink
chore: Fix clippy warnings (#3021)
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Degosserie <[email protected]>
Co-authored-by: Rodrigo Quelhas <[email protected]>
  • Loading branch information
3 people authored Dec 21, 2024
1 parent ef2aade commit 03010bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions precompiles/assets-erc20/src/eip2612.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ where
Address(address),
));

keccak_256(&domain_separator_inner).into()
keccak_256(&domain_separator_inner)
}

pub fn generate_permit(
Expand Down Expand Up @@ -181,6 +181,7 @@ where

// Translated from
// https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2ERC20.sol#L81
#[allow(clippy::too_many_arguments)]
pub(crate) fn permit(
asset_id: AssetIdOf<Runtime, Instance>,
handle: &mut impl PrecompileHandle,
Expand Down Expand Up @@ -220,8 +221,8 @@ where
);

let mut sig = [0u8; 65];
sig[0..32].copy_from_slice(&r.as_bytes());
sig[32..64].copy_from_slice(&s.as_bytes());
sig[0..32].copy_from_slice(r.as_bytes());
sig[32..64].copy_from_slice(s.as_bytes());
sig[64] = v;

let signer = sp_io::crypto::secp256k1_ecdsa_recover(&sig, &permit)
Expand Down
5 changes: 3 additions & 2 deletions precompiles/assets-erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub type AssetIdOf<Runtime, Instance = ()> = <Runtime as pallet_assets::Config<I
/// 1024-2047 Precompiles that are not in Ethereum Mainnet but are neither Moonbeam specific
/// 2048-4095 Moonbeam specific precompiles
/// Asset precompiles can only fall between
/// 0xFFFFFFFF00000000000000000000000000000000 - 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
/// 0xFFFFFFFF00000000000000000000000000000000 - 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
/// The precompile for AssetId X, where X is a u128 (i.e.16 bytes), if 0XFFFFFFFF + Bytes(AssetId)
/// In order to route the address to Erc20AssetsPrecompile<R>, we first check whether the AssetId
/// exists in pallet-assets
Expand Down Expand Up @@ -336,7 +336,7 @@ where
{
let caller: Runtime::AccountId =
Runtime::AddressMapping::into_account_id(handle.context().caller);
let from: Runtime::AccountId = Runtime::AddressMapping::into_account_id(from.clone());
let from: Runtime::AccountId = Runtime::AddressMapping::into_account_id(from);
let to: Runtime::AccountId = Runtime::AddressMapping::into_account_id(to);

// If caller is "from", it can spend as much as it wants from its own balance.
Expand Down Expand Up @@ -508,6 +508,7 @@ where
}

#[precompile::public("permit(address,address,uint256,uint256,uint8,bytes32,bytes32)")]
#[allow(clippy::too_many_arguments)]
fn eip2612_permit(
asset_id: AssetIdOf<Runtime, Instance>,
handle: &mut impl PrecompileHandle,
Expand Down
7 changes: 4 additions & 3 deletions precompiles/balances-erc20/src/eip2612.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ where
Address(address),
));

keccak_256(&domain_separator_inner).into()
keccak_256(&domain_separator_inner)
}

pub fn generate_permit(
Expand Down Expand Up @@ -92,6 +92,7 @@ where

// Translated from
// https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2ERC20.sol#L81
#[allow(clippy::too_many_arguments)]
pub(crate) fn permit(
handle: &mut impl PrecompileHandle,
owner: Address,
Expand Down Expand Up @@ -127,8 +128,8 @@ where
);

let mut sig = [0u8; 65];
sig[0..32].copy_from_slice(&r.as_bytes());
sig[32..64].copy_from_slice(&s.as_bytes());
sig[0..32].copy_from_slice(r.as_bytes());
sig[32..64].copy_from_slice(s.as_bytes());
sig[64] = v;

let signer = sp_io::crypto::secp256k1_ecdsa_recover(&sig, &permit)
Expand Down
5 changes: 3 additions & 2 deletions precompiles/balances-erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ where
Some(origin).into(),
pallet_balances::Call::<Runtime, Instance>::transfer_allow_death {
dest: Runtime::Lookup::unlookup(to),
value: value,
value,
},
SYSTEM_ACCOUNT_SIZE,
)?;
Expand Down Expand Up @@ -353,7 +353,7 @@ where
Some(from).into(),
pallet_balances::Call::<Runtime, Instance>::transfer_allow_death {
dest: Runtime::Lookup::unlookup(to),
value: value,
value,
},
SYSTEM_ACCOUNT_SIZE,
)?;
Expand Down Expand Up @@ -462,6 +462,7 @@ where
}

#[precompile::public("permit(address,address,uint256,uint256,uint8,bytes32,bytes32)")]
#[allow(clippy::too_many_arguments)]
fn eip2612_permit(
handle: &mut impl PrecompileHandle,
owner: Address,
Expand Down

0 comments on commit 03010bb

Please sign in to comment.