diff --git a/doc/.build b/doc/.build index 37f4ac7..16cb4fb 100644 --- a/doc/.build +++ b/doc/.build @@ -4,7 +4,7 @@ fonts/icomoon.eot fonts/icomoon.svg fonts/icomoon.ttf fonts/icomoon.woff -dist/sidebar_items-8f71fb01e6.js +dist/sidebar_items-fa0908e9e2.js api-reference.html search.html 404.html diff --git a/doc/404.html b/doc/404.html index e2e71dc..a3441fd 100644 --- a/doc/404.html +++ b/doc/404.html @@ -5,12 +5,12 @@ - 404 – exw3 v0.0.2 + 404 – exw3 v0.1.0 - + @@ -37,7 +37,7 @@ exw3 diff --git a/doc/ExW3.Contract.html b/doc/ExW3.Contract.html index 2f3b808..dd6fc96 100644 --- a/doc/ExW3.Contract.html +++ b/doc/ExW3.Contract.html @@ -5,12 +5,12 @@ - ExW3.Contract – exw3 v0.0.2 + ExW3.Contract – exw3 v0.1.0 - + @@ -37,7 +37,7 @@ exw3 @@ -71,10 +71,10 @@

- exw3 v0.0.2 + exw3 v0.1.0 ExW3.Contract - + View Source @@ -101,7 +101,19 @@

- at(abi, address) + address(pid) +
+ +
+
+
+ at(pid, address) +
+ +
+
+
+ call(pid, method_name, args \\ [])
@@ -116,34 +128,53 @@
- deploy(bin_filename, options) + deploy(pid, args) +
+ +
+
+
+ deploy_helper(bin, abi, args)
- get(contract, key) + eth_call_helper(address, abi, method_name, args)
- method(contract_agent, method_name, args \\ [], options \\ %{}) + eth_send_helper(address, abi, method_name, args, options)
- put(contract, key, value) + init(state)
-

Puts the value for the given key in the contract

+

Invoked when the server is started. start_link/3 or start/3 will +block until it returns

+ +
+
+ + +
+
+
@@ -167,7 +198,29 @@ Functions -
+
+ + + +
+ +
+
+
@@ -175,9 +228,33 @@ Link to this function - at(abi, address) + at(pid, address) + + + + View Source + + + + +
+
+ +
+
+
+ + + + +
+ + + Link to this function + + call(pid, method_name, args \\ []) - + View Source @@ -199,7 +276,7 @@ child_spec(arg) - + View Source @@ -221,9 +298,9 @@ Link to this function - deploy(bin_filename, options) + deploy(pid, args) - + View Source @@ -235,17 +312,17 @@
-
+
- + Link to this function - get(contract, key) + deploy_helper(bin, abi, args) - + View Source @@ -257,21 +334,39 @@
-
+
- +
+ + + Link to this function + + eth_call_helper(address, abi, method_name, args) + + + + View Source + + + + +
+
+ +
+
+
-
- + Link to this function - method(contract_agent, method_name, args \\ [], options \\ %{}) + eth_send_helper(address, abi, method_name, args, options) - + View Source @@ -283,17 +378,17 @@
-
+
- + Link to this function - put(contract, key, value) + init(state) - + View Source @@ -302,10 +397,84 @@
-

Puts the value for the given key in the contract.

+

Invoked when the server is started. start_link/3 or start/3 will +block until it returns.

+

args is the argument term (second argument) passed to start_link/3.

+

Returning {:ok, state} will cause start_link/3 to return +{:ok, pid} and the process to enter its loop.

+

Returning {:ok, state, timeout} is similar to {:ok, state} +except handle_info(:timeout, state) will be called after timeout +milliseconds if no messages are received within the timeout.

+

Returning {:ok, state, :hibernate} is similar to +{:ok, state} except the process is hibernated before entering the loop. See +c:handle_call/3 for more information on hibernation.

+

Returning :ignore will cause start_link/3 to return :ignore and the +process will exit normally without entering the loop or calling c:terminate/2. +If used when part of a supervision tree the parent supervisor will not fail +to start nor immediately try to restart the GenServer. The remainder of the +supervision tree will be (re)started and so the GenServer should not be +required by other processes. It can be started later with +Supervisor.restart_child/2 as the child specification is saved in the parent +supervisor. The main use cases for this are:

+
    +
  • The GenServer is disabled by configuration but might be enabled later. +
  • +
  • An error occurred and it will be handled by a different mechanism than the + Supervisor. Likely this approach involves calling Supervisor.restart_child/2 +after a delay to attempt a restart. +
  • +
+

Returning {:stop, reason} will cause start_link/3 to return +{:error, reason} and the process to exit with reason reason without +entering the loop or calling c:terminate/2.

+

Callback implementation for GenServer.init/1.

+
+ + +
+ + + Link to this function + + send(pid, method_name, args, options) + + + + View Source + + + + +
+
+ +
+
+
+ + +
+ + + Link to this function + + start_link(name, state) + + + + View Source + + + + +
+
+ +
+
@@ -314,9 +483,9 @@ Link to this function - tx_receipt(contract_agent, tx_hash) + tx_receipt(pid, tx_hash) - + View Source diff --git a/doc/ExW3.html b/doc/ExW3.html index e3bb357..f490dfb 100644 --- a/doc/ExW3.html +++ b/doc/ExW3.html @@ -5,12 +5,12 @@ - ExW3 – exw3 v0.0.2 + ExW3 – exw3 v0.1.0 - + @@ -37,7 +37,7 @@ exw3
@@ -71,7 +71,7 @@

- exw3 v0.0.2 + exw3 v0.1.0 ExW3 @@ -140,6 +140,12 @@ decode_output(abi, name, output)

+
+
@@ -152,6 +158,12 @@ encode_input(abi, name, input)
+
+
@@ -164,6 +176,18 @@ load_abi(file_path)
+
+ +
@@ -188,6 +212,12 @@ tx_receipt(tx_hash)
+
+
@@ -219,7 +249,7 @@ accounts() - + View Source @@ -241,7 +271,7 @@ balance(account) - + View Source @@ -263,7 +293,7 @@ block(block_number) - + View Source @@ -285,7 +315,7 @@ block_number() - + View Source @@ -307,7 +337,7 @@ bytes_to_string(bytes) - + View Source @@ -329,7 +359,7 @@ decode_event(data, signature) - + View Source @@ -351,7 +381,29 @@ decode_output(abi, name, output) - + + + View Source + + + + +
+
+ +
+
+
+ + +
+ + + Link to this function + + encode_data(types_signature, data) + + View Source @@ -373,7 +425,7 @@ encode_event(signature) - + View Source @@ -395,7 +447,29 @@ encode_input(abi, name, input) - + + + View Source + + + + +
+
+ +
+
+
+ + +
+ + + Link to this function + + encode_method_call(abi, name, input) + + View Source @@ -417,7 +491,7 @@ keys_to_decimal(map, keys) - + View Source @@ -439,7 +513,51 @@ load_abi(file_path) - + + + View Source + + + + +
+
+ +
+
+
+ + +
+ + + Link to this function + + load_bin(file_path) + + + + View Source + + + + +
+
+ +
+
+
+ + +
+ + + Link to this function + + method_signature(abi, name) + + View Source @@ -463,7 +581,7 @@ mine(num_blocks \\ 1) - + View Source @@ -485,7 +603,7 @@ reformat_abi(abi) - + View Source @@ -507,7 +625,7 @@ to_decimal(hex_string) - + View Source @@ -529,7 +647,29 @@ tx_receipt(tx_hash) - + + + View Source + + + + +
+
+ +
+
+
+ + +
+ + + Link to this function + + types_signature(abi, name) + + View Source diff --git a/doc/api-reference.html b/doc/api-reference.html index 5952972..595e8d3 100644 --- a/doc/api-reference.html +++ b/doc/api-reference.html @@ -5,12 +5,12 @@ - API Reference – exw3 v0.0.2 + API Reference – exw3 v0.1.0 - + @@ -37,7 +37,7 @@ exw3
@@ -71,7 +71,7 @@

- exw3 v0.0.2 + exw3 v0.1.0 API Reference

diff --git a/doc/dist/sidebar_items-8f71fb01e6.js b/doc/dist/sidebar_items-8f71fb01e6.js deleted file mode 100644 index c4f48d8..0000000 --- a/doc/dist/sidebar_items-8f71fb01e6.js +++ /dev/null @@ -1 +0,0 @@ -sidebarNodes={"extras":[{"id":"api-reference","title":"API Reference","group":"","headers":[{"id":"Modules","anchor":"modules"}]}],"exceptions":[],"modules":[{"id":"ExW3","title":"ExW3","group":"","functions":[{"id":"accounts/0","anchor":"accounts/0"},{"id":"balance/1","anchor":"balance/1"},{"id":"block/1","anchor":"block/1"},{"id":"block_number/0","anchor":"block_number/0"},{"id":"bytes_to_string/1","anchor":"bytes_to_string/1"},{"id":"decode_event/2","anchor":"decode_event/2"},{"id":"decode_output/3","anchor":"decode_output/3"},{"id":"encode_event/1","anchor":"encode_event/1"},{"id":"encode_input/3","anchor":"encode_input/3"},{"id":"keys_to_decimal/2","anchor":"keys_to_decimal/2"},{"id":"load_abi/1","anchor":"load_abi/1"},{"id":"mine/1","anchor":"mine/1"},{"id":"reformat_abi/1","anchor":"reformat_abi/1"},{"id":"to_decimal/1","anchor":"to_decimal/1"},{"id":"tx_receipt/1","anchor":"tx_receipt/1"}]},{"id":"ExW3.Contract","title":"ExW3.Contract","group":"","functions":[{"id":"at/2","anchor":"at/2"},{"id":"child_spec/1","anchor":"child_spec/1"},{"id":"deploy/2","anchor":"deploy/2"},{"id":"get/2","anchor":"get/2"},{"id":"method/4","anchor":"method/4"},{"id":"put/3","anchor":"put/3"},{"id":"tx_receipt/2","anchor":"tx_receipt/2"}]}],"tasks":[]} \ No newline at end of file diff --git a/doc/dist/sidebar_items-fa0908e9e2.js b/doc/dist/sidebar_items-fa0908e9e2.js new file mode 100644 index 0000000..9dbf043 --- /dev/null +++ b/doc/dist/sidebar_items-fa0908e9e2.js @@ -0,0 +1 @@ +sidebarNodes={"extras":[{"id":"api-reference","title":"API Reference","group":"","headers":[{"id":"Modules","anchor":"modules"}]}],"exceptions":[],"modules":[{"id":"ExW3","title":"ExW3","group":"","functions":[{"id":"accounts/0","anchor":"accounts/0"},{"id":"balance/1","anchor":"balance/1"},{"id":"block/1","anchor":"block/1"},{"id":"block_number/0","anchor":"block_number/0"},{"id":"bytes_to_string/1","anchor":"bytes_to_string/1"},{"id":"decode_event/2","anchor":"decode_event/2"},{"id":"decode_output/3","anchor":"decode_output/3"},{"id":"encode_data/2","anchor":"encode_data/2"},{"id":"encode_event/1","anchor":"encode_event/1"},{"id":"encode_input/3","anchor":"encode_input/3"},{"id":"encode_method_call/3","anchor":"encode_method_call/3"},{"id":"keys_to_decimal/2","anchor":"keys_to_decimal/2"},{"id":"load_abi/1","anchor":"load_abi/1"},{"id":"load_bin/1","anchor":"load_bin/1"},{"id":"method_signature/2","anchor":"method_signature/2"},{"id":"mine/1","anchor":"mine/1"},{"id":"reformat_abi/1","anchor":"reformat_abi/1"},{"id":"to_decimal/1","anchor":"to_decimal/1"},{"id":"tx_receipt/1","anchor":"tx_receipt/1"},{"id":"types_signature/2","anchor":"types_signature/2"}]},{"id":"ExW3.Contract","title":"ExW3.Contract","group":"","functions":[{"id":"address/1","anchor":"address/1"},{"id":"at/2","anchor":"at/2"},{"id":"call/3","anchor":"call/3"},{"id":"child_spec/1","anchor":"child_spec/1"},{"id":"deploy/2","anchor":"deploy/2"},{"id":"deploy_helper/3","anchor":"deploy_helper/3"},{"id":"eth_call_helper/4","anchor":"eth_call_helper/4"},{"id":"eth_send_helper/5","anchor":"eth_send_helper/5"},{"id":"init/1","anchor":"init/1"},{"id":"send/4","anchor":"send/4"},{"id":"start_link/2","anchor":"start_link/2"},{"id":"tx_receipt/2","anchor":"tx_receipt/2"}]}],"tasks":[]} \ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 7b8ce00..7e5314b 100644 --- a/doc/index.html +++ b/doc/index.html @@ -2,7 +2,7 @@ - exw3 v0.0.2 – Documentation + exw3 v0.1.0 – Documentation diff --git a/doc/search.html b/doc/search.html index 348b9bf..fc2905f 100644 --- a/doc/search.html +++ b/doc/search.html @@ -5,12 +5,12 @@ - Search – exw3 v0.0.2 + Search – exw3 v0.1.0 - + @@ -37,7 +37,7 @@ exw3
diff --git a/lib/exw3.ex b/lib/exw3.ex index d9b45a4..1954321 100644 --- a/lib/exw3.ex +++ b/lib/exw3.ex @@ -241,12 +241,17 @@ defmodule ExW3 do constructor_arg_data = if args[:args] do - {_, constructor} = Enum.find abi, fn {_, v} -> + constructor_abi = Enum.find abi, fn {_, v} -> v["type"] == "constructor" - end - input_types = Enum.map(constructor["inputs"], fn x -> x["type"] end) - types_signature = Enum.join(["(", Enum.join(input_types, ","), ")"]) - bin <> (ExW3.encode_data(types_signature, args[:args]) |> Base.encode16(case: :lower)) + end + if constructor_abi do + {_, constructor} = constructor_abi + input_types = Enum.map(constructor["inputs"], fn x -> x["type"] end) + types_signature = Enum.join(["(", Enum.join(input_types, ","), ")"]) + bin <> (ExW3.encode_data(types_signature, args[:args]) |> Base.encode16(case: :lower)) + else + bin + end else bin end