Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat committed Sep 10, 2024
1 parent 92443b9 commit 679f8b4
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 27 deletions.
16 changes: 10 additions & 6 deletions crates/contracts/src/account_contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ pub mod AccountContract {
};
use core::starknet::syscalls::{call_contract_syscall, replace_class_syscall};
use core::starknet::{
EthAddress, ClassHash, VALIDATED, get_caller_address, get_contract_address, get_tx_info,
get_block_timestamp
EthAddress, ClassHash, VALIDATED, get_caller_address, get_tx_info, get_block_timestamp
};
use core::traits::TryInto;
use openzeppelin::token::erc20::interface::{IERC20CamelDispatcher, IERC20CamelDispatcherTrait};
use super::{IAccountLibraryDispatcher, IAccountDispatcherTrait, OutsideExecution};
use utils::constants::{POW_2_32};
use utils::eth_transaction::transaction::{Transaction, TransactionTrait};
use utils::eth_transaction::transaction::Transaction;
use utils::eth_transaction::validation::validate_eth_tx;
use utils::eth_transaction::{EthTransactionTrait, TransactionMetadata};
use utils::serialization::{deserialize_signature, deserialize_bytes, serialize_bytes};
Expand Down Expand Up @@ -233,13 +232,18 @@ pub mod AccountContract {
.expect('conversion failed')
.span();

let chain_id: u64 = tx_info.chain_id.try_into().unwrap() % POW_2_32.try_into().unwrap();
let _chain_id: u64 = tx_info
.chain_id
.try_into()
.unwrap() % POW_2_32
.try_into()
.unwrap();

//TODO: add a type for unsigned transaction
let unsigned_transaction = EthTransactionTrait::decode(
encoded_tx_data, Default::default()
)
.expect('EOA: couldnt decode tx');
.expect('EOA: could not decode tx');

//TODO: validate as part of execute_from_outside
// let tx = EthTransactionTrait::decode(encoded_tx).expect('rlp decoding of tx failed');
Expand Down Expand Up @@ -338,7 +342,7 @@ pub mod AccountContract {
.expect('conversion to Span<u8> failed')
.span();
let signed_transaction = EthTransactionTrait::decode(encoded_tx_data, signature)
.expect('couldnt decode tx');
.expect('could not decode tx');
// TODO(execute-from-outside): move validation to KakarotCore
let tx_metadata = TransactionMetadata {
address: self.Account_evm_address.read(),
Expand Down
2 changes: 1 addition & 1 deletion crates/contracts/src/kakarot_core/interface.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::starknet::{ContractAddress, EthAddress, ClassHash};
use utils::eth_transaction::transaction::{Transaction, TransactionTrait};
use utils::eth_transaction::transaction::Transaction;

#[starknet::interface]
pub trait IKakarotCore<TContractState> {
Expand Down
1 change: 0 additions & 1 deletion crates/contracts/src/test_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use snforge_std::{
stop_cheat_caller_address, start_cheat_caller_address_global
};
use utils::constants::BLOCK_GAS_LIMIT;
use utils::eth_transaction::common::{TxKind, TxKindTrait};
use utils::eth_transaction::legacy::TxLegacy;


Expand Down
2 changes: 1 addition & 1 deletion crates/contracts/tests/test_execution_from_outside.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ fn test_execute_from_outside_invalid_signature() {
}

#[test]
#[should_panic(expected: 'EOA: couldnt decode tx')]
#[should_panic(expected: 'EOA: could not decode tx')]
fn test_execute_from_outside_invalid_tx() {
let (kakarot_core, contract_account) = set_up();

Expand Down
6 changes: 2 additions & 4 deletions crates/evm/src/gas.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::cmp::min;
use utils::eth_transaction::common::{TxKind, TxKindTrait};
use utils::eth_transaction::common::TxKindTrait;
use utils::eth_transaction::eip2930::{AccessListItem};
use utils::eth_transaction::transaction::{Transaction, TransactionTrait};
use utils::helpers;
Expand Down Expand Up @@ -266,11 +266,9 @@ mod tests {
ACCESS_LIST_STORAGE_KEY
};
use evm::test_utils::evm_address;
use utils::eth_transaction::common::{TxKind, TxKindTrait};
use utils::eth_transaction::eip1559::TxEip1559;
use utils::eth_transaction::eip2930::{AccessListItem, TxEip2930};
use utils::eth_transaction::legacy::TxLegacy;
use utils::eth_transaction::transaction::{Transaction, TransactionTrait};
use utils::eth_transaction::transaction::Transaction;
use utils::helpers::ToBytes;

#[test]
Expand Down
17 changes: 6 additions & 11 deletions crates/utils/src/eth_transaction.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use core::option::OptionTrait;
use core::starknet::{EthAddress, secp256_trait::Signature,};
use core::traits::TryInto;
use crate::eth_transaction::common::TxKind;
use eip1559::{TxEip1559, TxEip1559Trait};
use eip2930::{TxEip2930, TxEip2930Trait};
use eip1559::TxEip1559Trait;
use eip2930::TxEip2930Trait;
use legacy::TxLegacy;
use transaction::{Transaction, TransactionSigned, TransactionTrait};
use transaction::{Transaction, TransactionSigned};
use tx_type::TxType;
use utils::errors::{
RLPErrorTrait, EthTransactionError, RLPError, RLPErrorImpl, RLPHelpersErrorImpl,
Expand Down Expand Up @@ -302,19 +302,14 @@ fn get_effective_gas_price(
#[cfg(test)]
mod tests {
use core::option::OptionTrait;
use core::starknet::EthAddress;
use core::starknet::secp256_trait::{Signature};
use crate::eth_transaction::eip2930::AccessListItem;
use crate::eth_transaction::tx_type::TxType;
use crate::traits::DefaultSignature;
use evm::test_utils::chain_id;
use utils::eth_transaction::transaction::{Transaction, TransactionSigned, TransactionTrait};
use utils::eth_transaction::transaction::TransactionTrait;

use utils::eth_transaction::{
EthTransactionTrait, EncodedTransactionTrait, TransactionMetadata, EthTransactionError
};
use utils::helpers::{U256Trait, ToBytes};
use utils::rlp::{RLPTrait, RLPItem, RLPHelpersTrait};
use utils::eth_transaction::{EthTransactionTrait, EncodedTransactionTrait};
use utils::helpers::ToBytes;
use utils::test_data::{
legacy_rlp_encoded_tx, legacy_rlp_encoded_deploy_tx, eip_2930_encoded_tx,
eip_1559_encoded_tx
Expand Down
2 changes: 1 addition & 1 deletion crates/utils/src/eth_transaction/eip1559.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::num::traits::SaturatingSub;
use crate::errors::{EthTransactionError, RLPError, RLPHelpersErrorTrait};
use crate::eth_transaction::common::TxKind;
use crate::eth_transaction::eip2930::AccessListItem;
use crate::rlp::{RLPItem, RLPHelpersTrait, RLPTrait};
use crate::rlp::{RLPItem, RLPHelpersTrait};
use crate::traits::SpanDefault;

/// A transaction with a priority fee ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)).
Expand Down
2 changes: 1 addition & 1 deletion crates/utils/src/eth_transaction/eip2930.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::starknet::EthAddress;
use crate::errors::{EthTransactionError, RLPError, RLPHelpersErrorTrait};
use crate::eth_transaction::common::TxKind;
use crate::rlp::{RLPItem, RLPHelpersTrait, RLPTrait};
use crate::rlp::{RLPItem, RLPHelpersTrait};
use crate::traits::SpanDefault;


Expand Down
2 changes: 1 addition & 1 deletion crates/utils/src/eth_transaction/validation.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::starknet::eth_signature::verify_eth_signature;
use crate::eth_transaction::transaction::{Transaction, TransactionSigned, TransactionTrait};
use crate::eth_transaction::transaction::TransactionTrait;
use crate::eth_transaction::{TransactionMetadata, EthTransactionError, EthTransactionTrait};

/// Validate an Ethereum transaction
Expand Down

0 comments on commit 679f8b4

Please sign in to comment.