|
|
@ -541,6 +541,7 @@ defmodule ExW3 do |
|
|
|
) |
|
|
|
) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Casts |
|
|
|
# Casts |
|
|
|
|
|
|
|
|
|
|
|
def handle_cast({:at, address}, state) do |
|
|
|
def handle_cast({:at, address}, state) do |
|
|
@ -562,10 +563,15 @@ defmodule ExW3 do |
|
|
|
# Calls |
|
|
|
# Calls |
|
|
|
|
|
|
|
|
|
|
|
def handle_call({:deploy, args}, _from, state) do |
|
|
|
def handle_call({:deploy, args}, _from, state) do |
|
|
|
case {args[:bin], state[:bin]} do |
|
|
|
case {args[:options][:from], args[:options][:gas]} do |
|
|
|
{nil, nil} -> {:reply, {:error, "contract binary was never provided"}, state} |
|
|
|
{nil, _} -> {:reply, {:error, "transaction sender not provided"}, state} |
|
|
|
{bin, nil} -> {:reply, {:ok, deploy_helper(bin, state[:abi], args)}, state} |
|
|
|
{_, nil} -> {:reply, {:error, "gas amount not provided"}, state} |
|
|
|
{nil, bin} -> {:reply, {:ok, deploy_helper(bin, state[:abi], args)}, state} |
|
|
|
{_, _} -> |
|
|
|
|
|
|
|
case {args[:bin], state[:bin]} do |
|
|
|
|
|
|
|
{nil, nil} -> {:reply, {:error, "contract binary was never provided"}, state} |
|
|
|
|
|
|
|
{bin, nil} -> {:reply, {:ok, deploy_helper(bin, state[:abi], args)}, state} |
|
|
|
|
|
|
|
{nil, bin} -> {:reply, {:ok, deploy_helper(bin, state[:abi], args)}, state} |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -585,13 +591,19 @@ defmodule ExW3 do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def handle_call({:send, {method_name, args, options}}, _from, state) do |
|
|
|
def handle_call({:send, {method_name, args, options}}, _from, state) do |
|
|
|
address = state[:address] |
|
|
|
case {state[:address], options[:from], options[:gas]} do |
|
|
|
|
|
|
|
{nil, _, _} -> |
|
|
|
if address do |
|
|
|
{:reply, {:error, "contract address not available"}, state} |
|
|
|
result = eth_send_helper(address, state[:abi], Atom.to_string(method_name), args, options) |
|
|
|
{_, nil, _} -> |
|
|
|
{:reply, result, state} |
|
|
|
{:reply, {:error, "transaction sender not provided"}, state} |
|
|
|
else |
|
|
|
{_, _, nil} -> |
|
|
|
{:reply, {:error, "contract address not available"}, state} |
|
|
|
{:reply, {:error, "gas amount not provided"}, state} |
|
|
|
|
|
|
|
{address, _, _} -> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
:reply, |
|
|
|
|
|
|
|
eth_send_helper(address, state[:abi], Atom.to_string(method_name), args, options), |
|
|
|
|
|
|
|
state |
|
|
|
|
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|