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

Implementation of eth_get_transaction_count function #983

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 5 additions & 1 deletion crates/contracts/src/kakarot_core/eth_rpc.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ pub impl EthRPC<
}

fn eth_get_transaction_count(self: @TContractState, address: EthAddress) -> u64 {
panic!("unimplemented")
let kakarot_state = KakarotState::get_state();
Gerson2102 marked this conversation as resolved.
Show resolved Hide resolved
let starknet_address = kakarot_state.get_starknet_address(address);
let account = IAccountDispatcher { contract_address: starknet_address };
let nonce = account.get_nonce();
nonce
}

fn eth_chain_id(self: @TContractState) -> u64 {
Expand Down
4 changes: 3 additions & 1 deletion crates/evm/src/backend/validation.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ pub fn validate_eth_tx(kakarot_state: @KakarotCore::ContractState, tx: Transacti
// Validate nonce
let starknet_caller_address = get_caller_address();
let account = IAccountDispatcher { contract_address: starknet_caller_address };
assert(account.get_nonce() == tx.nonce(), 'Invalid nonce');
let eth_address = account.get_evm_address();
let nonce = kakarot_state.eth_get_transaction_count(eth_address);
assert(nonce == tx.nonce(), 'Invalid nonce');
Gerson2102 marked this conversation as resolved.
Show resolved Hide resolved

// Validate gas
let gas_limit = tx.gas_limit();
Expand Down
Loading