Skip to content

Commit

Permalink
fix: signature field fix
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Aug 1, 2024
1 parent 2cdd033 commit bf4482c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ape/api/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TransactionAPI(BaseInterfaceModel):
# If left as None, will get set to the network's default required confirmations.
required_confirmations: Optional[int] = Field(None, exclude=True)

signature: Optional[TransactionSignature] = None
signature: Optional[TransactionSignature] = Field(default=None, exclude=True)

model_config = ConfigDict(populate_by_name=True)

Expand Down Expand Up @@ -180,7 +180,7 @@ def receipt(self) -> Optional["ReceiptAPI"]:
"""

try:
txn_hash = self.txn_hash.hex()
txn_hash = to_hex(self.txn_hash)
except SignatureError:
return None

Expand Down
2 changes: 1 addition & 1 deletion src/ape_ethereum/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def serialize_transaction(self) -> bytes:

raise SignatureError(message)

txn_data = self.model_dump(by_alias=True, exclude={"sender", "type", "signature"})
txn_data = self.model_dump(by_alias=True, exclude={"sender", "type"})

# This messes up the signature
if txn_data.get("to") == ZERO_ADDRESS:
Expand Down
5 changes: 5 additions & 0 deletions src/ape_test/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ def send_transaction(self, txn: TransactionAPI) -> ReceiptAPI:
)
else:
txn_dict = txn_dict or txn.model_dump(mode="json")

# Signature is typically excluded from the model fields,
# so we have to include it manually.
txn_dict["signature"] = txn.signature

receipt = self.get_receipt(
txn_hash, required_confirmations=required_confirmations, transaction=txn_dict
)
Expand Down

0 comments on commit bf4482c

Please sign in to comment.