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

Support signed raw transactions in Ethers.send/2 #109

Merged
merged 1 commit into from
Apr 4, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Enhancements

- Support sending raw transactions using `Ethers.send/2`

## v0.4.1 (2024-04-02)

### Enhancements
Expand Down
4 changes: 4 additions & 0 deletions lib/ethers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,10 @@ defmodule Ethers do
end
end

defp pre_process("0x" <> _ = signed_tx, _overrides, :send, _opts) do
{:ok, signed_tx, :eth_send_raw_transaction}
end

defp pre_process(tx_data, overrides, :send = action, opts) do
tx_params = TxData.to_map(tx_data, overrides)

Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ defmodule Ethers.MixProject do
coveralls: :test,
"coveralls.detail": :test,
"coveralls.post": :test,
"coveralls.html": :test
"coveralls.html": :test,
test_prepare: :test
],
description:
"A comprehensive Web3 library for interacting with smart contracts on Ethereum using Elixir.",
Expand Down
2 changes: 1 addition & 1 deletion test/ethers_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ defmodule EthersTest do
tx_type: :eip1559
)

assert {:ok, _tx_hash} = Ethers.rpc_client().eth_send_raw_transaction(signed)
assert {:ok, _tx_hash} = Ethers.send(signed)

assert {:ok, "hi signed"} = Ethers.call(HelloWorldContract.say_hello(), to: address)
end
Expand Down
Loading