Skip to content

Commit

Permalink
fix: access list transaction had wrong attributes (#1851)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Jan 9, 2024
1 parent 456dac6 commit f8f5fbf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ape_ethereum/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ def prepare_transaction(self, txn: TransactionAPI) -> TransactionAPI:

txn_type = TransactionType(txn.type)
if (
txn_type == TransactionType.STATIC
txn_type in (TransactionType.STATIC, TransactionType.ACCESS_LIST)
and isinstance(txn, StaticFeeTransaction)
and txn.gas_price is None
):
Expand Down
5 changes: 3 additions & 2 deletions src/ape_ethereum/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ def check_type(cls, value):
return value.value if isinstance(value, TransactionType) else value


class AccessListTransaction(BaseTransaction):
class AccessListTransaction(StaticFeeTransaction):
"""
EIP-2930 transactions are similar to legacy transaction with an added access list functionality.
`EIP-2930 <https://eips.ethereum.org/EIPS/eip-2930>`__
transactions are similar to legacy transaction with an added access list functionality.
"""

gas_price: Optional[int] = Field(None, alias="gasPrice")
Expand Down
4 changes: 3 additions & 1 deletion src/ape_test/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def sign_message(self, msg: Any, **signer_options) -> Optional[MessageSignature]

def sign_transaction(self, txn: TransactionAPI, **signer_options) -> Optional[TransactionAPI]:
# Signs anything that's given to it
signature = EthAccount.sign_transaction(txn.model_dump(mode="json"), self.private_key)
signature = EthAccount.sign_transaction(
txn.model_dump(mode="json", by_alias=True), self.private_key
)
txn.signature = TransactionSignature(
v=signature.v,
r=to_bytes(signature.r),
Expand Down
8 changes: 6 additions & 2 deletions tests/functional/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ def test_create_dynamic_fee_kwargs(ethereum, fee_kwargs):
assert txn.max_fee == int(100e9)


def test_txn_hash_and_receipt(owner, eth_tester_provider, ethereum):
txn = ethereum.create_transaction()
@pytest.mark.parametrize(
"kwargs",
[{"type": 0}, {"type": 1}, {"type": 2, "max_fee": 1_000_000_000}],
)
def test_txn_hash_and_receipt(owner, eth_tester_provider, ethereum, kwargs):
txn = ethereum.create_transaction(**kwargs)
txn = owner.prepare_transaction(txn)
txn = owner.sign_transaction(txn)
assert txn
Expand Down

0 comments on commit f8f5fbf

Please sign in to comment.