Skip to content

Commit

Permalink
for clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Jul 5, 2023
1 parent 20c5474 commit a3070c1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
14 changes: 7 additions & 7 deletions core/src/ledger/eth_bridge/storage/wrapped_erc20s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::types::token::{

/// Construct a token address from an ERC20 address.
pub fn token(address: &EthAddress) -> Address {
Address::Internal(InternalAddress::Erc20(address.clone()))
Address::Internal(InternalAddress::Erc20(*address))
}

/// Represents the type of a key relating to a wrapped ERC20
Expand Down Expand Up @@ -47,12 +47,12 @@ impl From<&Key> for storage::Key {

/// Returns true if the given key has an ERC20 token
pub fn has_erc20_segment(key: &storage::Key) -> bool {
match key.segments.get(1) {
matches!(
key.segments.get(1),
Some(DbKeySeg::AddressSeg(Address::Internal(
InternalAddress::Erc20(_addr),
))) => true,
_ => false,
}
)))
)
}

impl TryFrom<(&Address, &storage::Key)> for Key {
Expand All @@ -72,7 +72,7 @@ impl TryFrom<(&Address, &storage::Key)> for Key {
InternalAddress::Erc20(addr),
))) = key.segments.get(1)
{
addr.clone()
*addr
} else {
return Err(eyre!(
"key has an incorrect segment at index #2, expected an \
Expand Down Expand Up @@ -207,7 +207,7 @@ mod test {
DbKeySeg::StringSeg(supply_key_seg),
] if multitoken_addr == &MULTITOKEN_ADDRESS &&
token_addr == &dai_erc20_token() &&
balance_key_seg == &BALANCE_STORAGE_KEY &&
balance_key_seg == BALANCE_STORAGE_KEY &&
supply_key_seg == MINTED_STORAGE_KEY
);

Expand Down
28 changes: 13 additions & 15 deletions shared/src/ledger/native_vp/ethereum_bridge/vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ where
)? {
// Multitoken VP checks the balance changes for the ERC20 transfer
Some(CheckType::Erc20Transfer) => Ok(true),
Some(CheckType::Escrow) => return self.check_escrow(verifiers),
Some(CheckType::Escrow) => self.check_escrow(verifiers),
None => Ok(false),
}
}
Expand Down Expand Up @@ -238,27 +238,25 @@ pub(super) fn check_balance_changes(
receiver: &Key,
) -> Result<Option<Amount>> {
let sender_balance_pre = reader
.read_pre_value::<Amount>(&sender)?
.read_pre_value::<Amount>(sender)?
.unwrap_or_default()
.change();
let sender_balance_post =
match reader.read_post_value::<Amount>(&sender)? {
Some(value) => value,
None => {
return Err(eyre!(
"Rejecting transaction as could not read_post balance key \
{}",
sender,
));
}
let sender_balance_post = match reader.read_post_value::<Amount>(sender)? {
Some(value) => value,
None => {
return Err(eyre!(
"Rejecting transaction as could not read_post balance key {}",
sender,
));
}
.change();
}
.change();
let receiver_balance_pre = reader
.read_pre_value::<Amount>(&receiver)?
.read_pre_value::<Amount>(receiver)?
.unwrap_or_default()
.change();
let receiver_balance_post = match reader
.read_post_value::<Amount>(&receiver)?
.read_post_value::<Amount>(receiver)?
{
Some(value) => value,
None => {
Expand Down
1 change: 1 addition & 0 deletions tests/src/e2e/eth_bridge_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::str::FromStr;

use borsh::{BorshDeserialize, BorshSerialize};
use color_eyre::eyre::{eyre, Result};
use expectrl::ControlCode;
use namada::eth_bridge::oracle;
use namada::eth_bridge::storage::vote_tallies;
use namada::ledger::eth_bridge::{
Expand Down

0 comments on commit a3070c1

Please sign in to comment.