Skip to content

Commit

Permalink
Fix rlp_encode_signed_data util (#1454)
Browse files Browse the repository at this point in the history
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1454)
<!-- Reviewable:end -->
  • Loading branch information
ClementWalter authored Sep 30, 2024
1 parent 7411a55 commit 3276a32
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions tests/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,21 @@ def rlp_encode_signed_data(tx: dict) -> bytes:
rlp_serializer = (
typed_transaction.transaction.__class__._unsigned_transaction_serializer
)
encoded_unsigned_tx = [
return [
typed_transaction.transaction_type,
*rlp.encode(rlp_serializer.from_dict(sanitized_transaction)),
]

return encoded_unsigned_tx
else:
legacy_tx = (
[
tx["nonce"],
tx["gasPrice"],
tx["gas"],
int(tx["to"], 16),
tx["value"],
tx["data"],
tx["chainId"],
0,
0,
]
if "chainId" in tx
else [
tx["nonce"],
tx["gasPrice"],
tx["gas"],
int(tx["to"], 16),
tx["value"],
tx["data"],
]
)
encoded_unsigned_tx = rlp.encode(legacy_tx)

return encoded_unsigned_tx
legacy_tx = [
tx["nonce"],
tx["gasPrice"],
tx["gas"] if "gas" in tx else tx["gasLimit"],
bytes.fromhex(f"{int(tx['to'], 16):040x}"),
tx["value"],
tx["data"],
] + ([tx["chainId"], 0, 0] if "chainId" in tx else [])

return rlp.encode(legacy_tx)


def hex_string_to_bytes_array(h: str):
Expand Down

0 comments on commit 3276a32

Please sign in to comment.