Skip to content

Commit

Permalink
fix: clippy checks
Browse files Browse the repository at this point in the history
  • Loading branch information
borispovod committed Nov 24, 2023
1 parent 03e28ae commit aa5d896
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions bin/magi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ impl TryFrom<Cli> for CliConfig {
/// The incoming value is the path to the key or a string with the key.
/// The private key must be in hexadecimal format with a length of 64 characters.
fn parse_secret_key_from_cli(value: &str) -> Result<SecretKey> {
secret_key_from_hex(value).or_else(|err| {
let path = PathBuf::try_from(value).map_err(|_| err)?;
secret_key_from_hex(value).or_else(|_| {
let path = PathBuf::from(value);
let key_string = fs::read_to_string(&path)
.map_err(|_| anyhow!("The key file {path:?} was not found."))?
.trim()
Expand Down
2 changes: 1 addition & 1 deletion src/derive/stages/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ mod tests {
assert_eq!(transactions.len(), 2, "wrong transactions length");

let (deposited_epoch, seq_number) =
transactions.get(0).unwrap().derive_unsafe_epoch().unwrap();
transactions.first().unwrap().derive_unsafe_epoch().unwrap();
assert_eq!(
deposited_epoch, new_epoch,
"wrong epoch in deposited transaction"
Expand Down
2 changes: 1 addition & 1 deletion src/l1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl InnerWatcher {

let input = &block
.transactions
.get(0)
.first()
.expect(
"Could not find the L1 attributes deposited transaction in the parent L2 block",
)
Expand Down
6 changes: 3 additions & 3 deletions src/types/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl RawTransaction {
pub fn derive_unsafe_epoch(&self) -> Result<(Epoch, u64)> {
let rlp = Rlp::new(self.0.as_slice());
let tx = rlp.as_val::<DepositedTransaction>()?;
let calldata = Bytes::try_from(tx.data)?;
let calldata = Bytes::from(tx.data);
let attr = AttributesDepositedCall::try_from(calldata)?;
let epoch = Epoch::from(&attr);

Expand Down Expand Up @@ -335,8 +335,8 @@ impl TryFrom<Log> for UserDeposited {
.into_bytes()
.unwrap();

let from = Address::try_from(log.topics[1])?;
let to = Address::try_from(log.topics[2])?;
let from = Address::from(log.topics[1]);
let to = Address::from(log.topics[2]);
let mint = U256::from_big_endian(&opaque_data[0..32]);
let value = U256::from_big_endian(&opaque_data[32..64]);
let gas = u64::from_be_bytes(opaque_data[64..72].try_into()?);
Expand Down
4 changes: 2 additions & 2 deletions src/types/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl TryFrom<&ExecutionPayload> for HeadInfo {
fn try_from(payload: &ExecutionPayload) -> Result<Self> {
let (epoch, seq_number) = payload
.transactions
.get(0)
.first()
.ok_or(eyre::eyre!("no deposit transaction"))?
.derive_unsafe_epoch()?;

Expand All @@ -117,7 +117,7 @@ impl TryFrom<Block<Transaction>> for HeadInfo {
fn try_from(block: Block<Transaction>) -> std::result::Result<Self, Self::Error> {
let tx_calldata = block
.transactions
.get(0)
.first()
.ok_or(eyre::eyre!(
"Could not find the L1 attributes deposited transaction"
))?
Expand Down

0 comments on commit aa5d896

Please sign in to comment.