4
0
Fork 0

Merge branch 'deployment_tx_hash' into error_messages

# Conflicts:
#	lib/exw3.ex
pull/12/head
Piotr Żelazko 6 years ago
commit 8d3701478b
No known key found for this signature in database
GPG Key ID: 27E11A19853A7913
  1. 9
      lib/exw3.ex
  2. 14
      test/exw3_test.exs

@ -513,11 +513,11 @@ defmodule ExW3 do
gas: "0x#{gas}" gas: "0x#{gas}"
} }
{:ok, tx_receipt_id} = Ethereumex.HttpClient.eth_send_transaction(tx) {:ok, tx_hash} = Ethereumex.HttpClient.eth_send_transaction(tx)
{:ok, tx_receipt} = Ethereumex.HttpClient.eth_get_transaction_receipt(tx_receipt_id) {:ok, tx_receipt} = Ethereumex.HttpClient.eth_get_transaction_receipt(tx_hash)
tx_receipt["contractAddress"] {tx_receipt["contractAddress"], tx_hash}
end end
def eth_call_helper(address, abi, method_name, args) do def eth_call_helper(address, abi, method_name, args) do
@ -580,7 +580,8 @@ defmodule ExW3 do
{:ok,_} <- check_option(args[:options][:gas], :missing_gas), {:ok,_} <- check_option(args[:options][:gas], :missing_gas),
{:ok, bin} <- check_option([state[:bin], args[:bin]], :missing_binary) {:ok, bin} <- check_option([state[:bin], args[:bin]], :missing_binary)
do do
result = {:ok, deploy_helper(bin, state[:abi], args)} {contract_addr, tx_hash} = deploy_helper(bin, state[:abi], args)
result = {:ok, contract_addr, tx_hash}
{:reply, result , state} {:reply, result , state}
else else
err -> {:reply, err, state} err -> {:reply, err, state}

@ -60,7 +60,7 @@ defmodule EXW3Test do
test "starts a Contract GenServer for simple storage contract", context do test "starts a Contract GenServer for simple storage contract", context do
ExW3.Contract.start_link(SimpleStorage, abi: context[:simple_storage_abi]) ExW3.Contract.start_link(SimpleStorage, abi: context[:simple_storage_abi])
{:ok, address} = {:ok, address, _} =
ExW3.Contract.deploy( ExW3.Contract.deploy(
SimpleStorage, SimpleStorage,
bin: ExW3.load_bin("test/examples/build/SimpleStorage.bin"), bin: ExW3.load_bin("test/examples/build/SimpleStorage.bin"),
@ -89,7 +89,7 @@ defmodule EXW3Test do
test "starts a Contract GenServer for array tester contract", context do test "starts a Contract GenServer for array tester contract", context do
ExW3.Contract.start_link(ArrayTester, abi: context[:array_tester_abi]) ExW3.Contract.start_link(ArrayTester, abi: context[:array_tester_abi])
{:ok, address} = {:ok, address, _} =
ExW3.Contract.deploy( ExW3.Contract.deploy(
ArrayTester, ArrayTester,
bin: ExW3.load_bin("test/examples/build/ArrayTester.bin"), bin: ExW3.load_bin("test/examples/build/ArrayTester.bin"),
@ -117,7 +117,7 @@ defmodule EXW3Test do
test "starts a Contract GenServer for event tester contract", context do test "starts a Contract GenServer for event tester contract", context do
ExW3.Contract.start_link(EventTester, abi: context[:event_tester_abi]) ExW3.Contract.start_link(EventTester, abi: context[:event_tester_abi])
{:ok, address} = {:ok, address, _} =
ExW3.Contract.deploy( ExW3.Contract.deploy(
EventTester, EventTester,
bin: ExW3.load_bin("test/examples/build/EventTester.bin"), bin: ExW3.load_bin("test/examples/build/EventTester.bin"),
@ -153,7 +153,7 @@ defmodule EXW3Test do
test "starts a Contract GenServer and uses the event listener", context do test "starts a Contract GenServer and uses the event listener", context do
ExW3.Contract.start_link(EventTester, abi: context[:event_tester_abi]) ExW3.Contract.start_link(EventTester, abi: context[:event_tester_abi])
{:ok, address} = {:ok, address, _} =
ExW3.Contract.deploy( ExW3.Contract.deploy(
EventTester, EventTester,
bin: ExW3.load_bin("test/examples/build/EventTester.bin"), bin: ExW3.load_bin("test/examples/build/EventTester.bin"),
@ -200,7 +200,7 @@ defmodule EXW3Test do
test "starts a Contract GenServer for Complex contract", context do test "starts a Contract GenServer for Complex contract", context do
ExW3.Contract.start_link(Complex, abi: context[:complex_abi]) ExW3.Contract.start_link(Complex, abi: context[:complex_abi])
{:ok, address} = {:ok, address, _} =
ExW3.Contract.deploy( ExW3.Contract.deploy(
Complex, Complex,
bin: ExW3.load_bin("test/examples/build/Complex.bin"), bin: ExW3.load_bin("test/examples/build/Complex.bin"),
@ -225,7 +225,7 @@ defmodule EXW3Test do
test "starts a Contract GenServer for AddressTester contract", context do test "starts a Contract GenServer for AddressTester contract", context do
ExW3.Contract.start_link(AddressTester, abi: context[:address_tester_abi]) ExW3.Contract.start_link(AddressTester, abi: context[:address_tester_abi])
{:ok, address} = {:ok, address, _} =
ExW3.Contract.deploy( ExW3.Contract.deploy(
AddressTester, AddressTester,
bin: ExW3.load_bin("test/examples/build/AddressTester.bin"), bin: ExW3.load_bin("test/examples/build/AddressTester.bin"),
@ -320,7 +320,7 @@ defmodule EXW3Test do
test "return proper error messages at send and call", context do test "return proper error messages at send and call", context do
ExW3.Contract.start_link(SimpleStorage, abi: context[:simple_storage_abi]) ExW3.Contract.start_link(SimpleStorage, abi: context[:simple_storage_abi])
{:ok, address} = {:ok, address, _} =
ExW3.Contract.deploy( ExW3.Contract.deploy(
SimpleStorage, SimpleStorage,
bin: ExW3.load_bin("test/examples/build/SimpleStorage.bin"), bin: ExW3.load_bin("test/examples/build/SimpleStorage.bin"),

Loading…
Cancel
Save