Skip to content

Commit e9309d7

Browse files
committed
Can't subscript transactions
1 parent ca1d795 commit e9309d7

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

src/ethereum/cancun/exceptions.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
Exceptions specific to this fork.
33
"""
44

5-
from typing import Final
5+
from typing import TYPE_CHECKING, Final
66

77
from ethereum_types.numeric import Uint
88

99
from ethereum.exceptions import InvalidTransaction
1010

11+
if TYPE_CHECKING:
12+
from .transactions import Transaction
13+
1114

1215
class TransactionTypeError(InvalidTransaction):
1316
"""
@@ -28,20 +31,20 @@ def __init__(self, transaction_type: int):
2831

2932
class TransactionTypeContractCreationError(InvalidTransaction):
3033
"""
31-
Transaction type is not allowed for contract creation.
34+
Contract creation is not allowed for a transaction type.
3235
"""
3336

34-
transaction_type: Final[int]
37+
transaction: "Transaction"
3538
"""
36-
The type byte of the transaction that caused the error.
39+
The transaction that caused the error.
3740
"""
3841

39-
def __init__(self, transaction_type: int):
42+
def __init__(self, transaction: "Transaction"):
4043
super().__init__(
41-
f"transaction type `{transaction_type}` not allowed for "
42-
"contract creation"
44+
f"transaction type `{type(transaction).__name__}` not allowed to "
45+
"create contracts"
4346
)
44-
self.transaction_type = transaction_type
47+
self.transaction = transaction
4548

4649

4750
class BlobGasLimitExceededError(InvalidTransaction):

src/ethereum/cancun/fork.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def check_transaction(
451451

452452
if isinstance(tx, BlobTransaction):
453453
if not isinstance(tx.to, Address):
454-
raise TransactionTypeContractCreationError(tx[0])
454+
raise TransactionTypeContractCreationError(tx)
455455
if len(tx.blob_versioned_hashes) == 0:
456456
raise NoBlobDataError("no blob data in transaction")
457457
for blob_versioned_hash in tx.blob_versioned_hashes:

src/ethereum/prague/exceptions.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
Exceptions specific to this fork.
33
"""
44

5-
from typing import Final
5+
from typing import TYPE_CHECKING, Final
66

77
from ethereum_types.numeric import Uint
88

99
from ethereum.exceptions import InvalidTransaction
1010

11+
if TYPE_CHECKING:
12+
from .transactions import Transaction
13+
1114

1215
class TransactionTypeError(InvalidTransaction):
1316
"""
@@ -28,20 +31,20 @@ def __init__(self, transaction_type: int):
2831

2932
class TransactionTypeContractCreationError(InvalidTransaction):
3033
"""
31-
Transaction type is not allowed for contract creation.
34+
Contract creation is not allowed for a transaction type.
3235
"""
3336

34-
transaction_type: Final[int]
37+
transaction: "Transaction"
3538
"""
36-
The type byte of the transaction that caused the error.
39+
The transaction that caused the error.
3740
"""
3841

39-
def __init__(self, transaction_type: int):
42+
def __init__(self, transaction: "Transaction"):
4043
super().__init__(
41-
f"transaction type `{transaction_type}` not allowed for "
42-
"contract creation"
44+
f"transaction type `{type(transaction).__name__}` not allowed to "
45+
"create contracts"
4346
)
44-
self.transaction_type = transaction_type
47+
self.transaction = transaction
4548

4649

4750
class BlobGasLimitExceededError(InvalidTransaction):

src/ethereum/prague/fork.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def check_transaction(
502502

503503
if isinstance(tx, (BlobTransaction, SetCodeTransaction)):
504504
if not isinstance(tx.to, Address):
505-
raise TransactionTypeContractCreationError(tx[0])
505+
raise TransactionTypeContractCreationError(tx)
506506

507507
if isinstance(tx, SetCodeTransaction):
508508
if not any(tx.authorizations):

0 commit comments

Comments
 (0)