Skip to content

Commit

Permalink
fix: delete unused, misleading, and error-prone method (#2509)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Feb 16, 2025
1 parent d927196 commit 2a365bc
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions src/ape/api/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any, ClassVar, Optional, Union

from eth_account import Account as EthAccount
from eth_account._utils.signing import (
encode_transaction,
serializable_unsigned_transaction_from_dict,
)
from eth_pydantic_types import HexBytes
from eth_utils import keccak, to_int
from eth_utils import keccak
from evmchains import PUBLIC_CHAIN_META
from pydantic import model_validator

Expand All @@ -22,7 +17,6 @@
NetworkNotFoundError,
ProviderNotConnectedError,
ProviderNotFoundError,
SignatureError,
)
from ape.logging import logger
from ape.types.address import AddressType
Expand Down Expand Up @@ -218,31 +212,6 @@ def encode_contract_blueprint( # type: ignore[empty-body]
:class:`~ape.ape.transactions.TransactionAPI`
"""

def serialize_transaction(self) -> bytes:
"""
Serialize a transaction to bytes.
Returns:
bytes
"""
if not self.signature:
raise SignatureError("The transaction is not signed.")

txn_data = self.model_dump(exclude={"sender"})
unsigned_txn = serializable_unsigned_transaction_from_dict(txn_data)
signature = (
self.signature.v,
to_int(self.signature.r),
to_int(self.signature.s),
)

signed_txn = encode_transaction(unsigned_txn, signature)

if self.sender and EthAccount.recover_transaction(signed_txn) != self.sender:
raise SignatureError("Recovered signer doesn't match sender!")

return signed_txn

@abstractmethod
def decode_receipt(self, data: dict) -> "ReceiptAPI":
"""
Expand Down

0 comments on commit 2a365bc

Please sign in to comment.