Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix clippy warnings #3021

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions precompiles/assets-erc20/src/eip2612.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ where
Address(address),
));

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

pub fn generate_permit(
Expand Down Expand Up @@ -180,6 +180,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 @@ -219,8 +220,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 @@ -66,7 +66,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 @@ -334,7 +334,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 @@ -506,6 +506,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 @@ -59,7 +59,7 @@ where
Address(address),
));

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

pub fn generate_permit(
Expand Down Expand Up @@ -91,6 +91,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 @@ -126,8 +127,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 @@ -286,7 +286,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 @@ -352,7 +352,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 @@ -461,6 +461,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