Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rlp_encode_signed_data util #1454

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading