Skip to content

Conversation

@alisinabh
Copy link
Member

@alisinabh alisinabh commented Oct 17, 2025

This PR fixes two critical issues in Transaction.from_rpc_map/1 that were causing incorrect transaction parsing from RPC responses.

Fixes #225

Changes Made

Fix input/data field decoding

  • Changed from from_map_value/2 to from_map_value_bin/2 for input and data fields
  • Added fallback to empty string "" when both fields are missing or nil
  • Ensures proper hex decoding to binary format as expected by the rest of the codebase

Fix signature handling for nil values

  • Added guard clause to maybe_wrap_signed/2 to ensure transaction is not nil
  • Added explicit handling for {:ok, nil} case in signature_r matching
  • Prevents crashes when signature_r is present but set to nil

@alisinabh alisinabh requested a review from Copilot October 17, 2025 02:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes incorrect decoding of transaction input/data fields from RPC maps and improves signature handling to avoid crashes when signature fields are nil.

  • Decode input/data using from_map_value_bin/2 and default to empty binary string when absent
  • Add guard and explicit handling around signature_r to avoid wrapping when signature is nil
  • Expand test coverage for from_rpc_map across transaction types and key formats; update integration test to assert input and transaction hash

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
lib/ethers/transaction.ex Fixes input/data decoding to binary with fallback and adjusts signature handling in maybe_wrap_signed/2
test/ethers_test.exs Updates integration test to assert decoded input and transaction hash
test/ethers/transaction_test.exs Adds comprehensive tests for from_rpc_map/1 across input/data permutations and tx types
CHANGELOG.md Documents bug fixes for input decoding and signature handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

alisinabh and others added 3 commits October 16, 2025 23:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@alisinabh alisinabh merged commit a3bf824 into main Oct 17, 2025
5 checks passed
@alisinabh alisinabh deleted the fix-input-decoding branch October 17, 2025 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect input decoding from RPC transaction maps

1 participant