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 transaction hex_decode when deploy with local-signer #145

Merged
merged 1 commit into from
Oct 18, 2024
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
1 change: 1 addition & 0 deletions lib/ethers/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ defmodule Ethers.Transaction do

defp do_post_process(_key, {:error, reason}), do: {:error, reason}

defp hex_decode(nil), do: ""
defp hex_decode(""), do: ""
defp hex_decode("0x"), do: ""

Expand Down
18 changes: 18 additions & 0 deletions test/ethers/counter_contract_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defmodule Ethers.CounterContractTest do
alias Ethers.Contract.Test.CounterContract

@from "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
@from_private_key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

describe "contract deployment" do
test "Can deploy a contract on blockchain" do
Expand All @@ -29,6 +30,23 @@ defmodule Ethers.CounterContractTest do

assert {:ok, _address} = Ethers.deployed_address(tx_hash)
end

test "Can deploy a contract with local signer" do
encoded_constructor = CounterContract.constructor(100)

assert {:ok, tx_hash} =
Ethers.deploy(CounterContract,
encoded_constructor: encoded_constructor,
from: @from,
signer: Ethers.Signer.Local,
signer_opts: [private_key: @from_private_key]
)

wait_for_transaction!(tx_hash)

assert {:ok, address} = Ethers.deployed_address(tx_hash)
assert {:ok, 100} = CounterContract.get() |> Ethers.call(to: address)
end
end

describe "inspecting function calls" do
Expand Down
Loading