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 protocol typo #197

Merged
merged 1 commit into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/ethers/transaction/signed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ defmodule Ethers.Transaction.Signed do
defimpl Transaction.Protocol do
import Ethers.Utils, only: [remove_leading_zeros: 1]

def type_id(signed_tx), do: Transaction.Protocol.type_id(signed_tx.pyalod)
def type_id(signed_tx), do: Transaction.Protocol.type_id(signed_tx.payload)

def type_envelope(signed_tx), do: Transaction.Protocol.type_envelope(signed_tx.payload)

Expand Down
37 changes: 37 additions & 0 deletions test/ethers/transaction_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,41 @@ defmodule Ethers.TransactionTest do
assert Ethers.Utils.hex_encode(Transaction.encode(decoded_tx)) == raw_tx
end
end

test "ensure correct signer type_ids and type_envelopes" do
types = [
Transaction.Legacy,
Transaction.Eip1559,
Transaction.Eip2930,
Transaction.Eip4844
]

for type <- types do
{:ok, tx} =
type.new(%{
nonce: 0,
gas_price: 1,
gas: 21_000,
to: nil,
value: 0,
input: "",
chain_id: 1,
max_priority_fee_per_gas: 1,
max_fee_per_blob_gas: 1,
max_fee_per_gas: 1,
access_list: []
})

{:ok, signed_tx} =
Transaction.Signed.new(%{
payload: tx,
signature_r: <<1::256>>,
signature_s: <<2::256>>,
signature_y_parity_or_v: 27
})

assert Transaction.Protocol.type_id(signed_tx) == type.type_id()
assert Transaction.Protocol.type_envelope(signed_tx) == type.type_envelope()
end
end
end
Loading