diff --git a/lib/exw3.ex b/lib/exw3.ex index 0159a5e..f1cc509 100644 --- a/lib/exw3.ex +++ b/lib/exw3.ex @@ -188,7 +188,16 @@ defmodule ExW3 do @spec reformat_abi([]) :: %{} @doc "Reformats abi from list to map with event and function names as keys" def reformat_abi(abi) do - Map.new(Enum.map(abi, fn x -> {x["name"], x} end)) + Map.new(Enum.map( + abi, + fn x -> + case {x["name"], x["type"]} do + {nil, "constructor"} -> {"constructor", x} + {nil, "fallback"} -> {"fallback", x} + {name, _} -> {x["name"], x} + end + end + )) end @spec load_abi(binary()) :: [] diff --git a/test/examples/build/Complex.abi b/test/examples/build/Complex.abi index 4a3622b..b0270b2 100644 --- a/test/examples/build/Complex.abi +++ b/test/examples/build/Complex.abi @@ -1 +1 @@ -[{"constant":true,"inputs":[],"name":"getBroAndBroBro","outputs":[{"name":"bro","type":"uint256"},{"name":"broBro","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getBarFoo","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_foobar","type":"bytes32"}],"name":"setFooBar","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getBoth","outputs":[{"name":"","type":"uint256"},{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_barFoo","type":"bool"}],"name":"setBarFoo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_fooboo","type":"uint256"}],"name":"getFooBoo","outputs":[{"name":"fooBoo","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"getFooBar","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_foo","type":"uint256"}],"name":"setFoo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_foo","type":"uint256"},{"name":"_foobar","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"foo","type":"uint256"},{"indexed":false,"name":"person","type":"address"}],"name":"Bar","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"fooboo","type":"bool"},{"indexed":false,"name":"foo","type":"uint256"},{"indexed":false,"name":"foobar","type":"bytes32"}],"name":"FooBar","type":"event"}] \ No newline at end of file +[{"constant":true,"inputs":[],"name":"getBroAndBroBro","outputs":[{"name":"bro","type":"uint256"},{"name":"broBro","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getBarFoo","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_foobar","type":"bytes32"}],"name":"setFooBar","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getBoth","outputs":[{"name":"","type":"uint256"},{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_barFoo","type":"bool"}],"name":"setBarFoo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_fooboo","type":"uint256"}],"name":"getFooBoo","outputs":[{"name":"fooBoo","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"getFooBar","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_foo","type":"uint256"}],"name":"setFoo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_foo","type":"uint256"},{"name":"_foobar","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"foo","type":"uint256"},{"indexed":false,"name":"person","type":"address"}],"name":"Bar","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"fooboo","type":"bool"},{"indexed":false,"name":"foo","type":"uint256"},{"indexed":false,"name":"foobar","type":"bytes32"}],"name":"FooBar","type":"event"}] \ No newline at end of file diff --git a/test/examples/build/Complex.bin b/test/examples/build/Complex.bin index 54468e8..8670527 100644 --- a/test/examples/build/Complex.bin +++ b/test/examples/build/Complex.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b5060405160408061034b833981018060405281019080805190602001909291908051906020019092919050505081600081905550806001816000191690555050506102eb806100606000396000f30060806040526004361061008e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631b85502e1461009357806354fcb8a6146100cd5780637b07059b146100fc57806393affe511461012d5780639aa7c12014610167578063b17e413b14610196578063cfd91f2b146101d7578063dc80035d1461020a575b600080fd5b34801561009f57600080fd5b506100a8610237565b6040518083815260200182600019166000191681526020019250505060405180910390f35b3480156100d957600080fd5b506100e261024b565b604051808215151515815260200191505060405180910390f35b34801561010857600080fd5b5061012b6004803603810190808035600019169060200190929190505050610262565b005b34801561013957600080fd5b50610142610270565b6040518083815260200182600019166000191681526020019250505060405180910390f35b34801561017357600080fd5b50610194600480360381019080803515159060200190929190505050610281565b005b3480156101a257600080fd5b506101c16004803603810190808035906020019092919050505061029e565b6040518082815260200191505060405180910390f35b3480156101e357600080fd5b506101ec6102ab565b60405180826000191660001916815260200191505060405180910390f35b34801561021657600080fd5b50610235600480360381019080803590602001909291905050506102b5565b005b600080602a60005401600154915091509091565b6000600260009054906101000a900460ff16905090565b806001816000191690555050565b600080600054600154915091509091565b80600260006101000a81548160ff02191690831515021790555050565b6000602a82019050919050565b6000600154905090565b80600081905550505600a165627a7a72305820c499af61834354392e660b8e8a29d6fa2e4f64fc70e8876e171cdaa1959e4c9c0029 \ No newline at end of file +608060405234801561001057600080fd5b50604051604080610348833981018060405281019080805190602001909291908051906020019092919050505081600081905550806001816000191690555050506102e8806100606000396000f30060806040526004361061008e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631b85502e1461009057806354fcb8a6146100ca5780637b07059b146100f957806393affe511461012a5780639aa7c12014610164578063b17e413b14610193578063cfd91f2b146101d4578063dc80035d14610207575b005b34801561009c57600080fd5b506100a5610234565b6040518083815260200182600019166000191681526020019250505060405180910390f35b3480156100d657600080fd5b506100df610248565b604051808215151515815260200191505060405180910390f35b34801561010557600080fd5b50610128600480360381019080803560001916906020019092919050505061025f565b005b34801561013657600080fd5b5061013f61026d565b6040518083815260200182600019166000191681526020019250505060405180910390f35b34801561017057600080fd5b5061019160048036038101908080351515906020019092919050505061027e565b005b34801561019f57600080fd5b506101be6004803603810190808035906020019092919050505061029b565b6040518082815260200191505060405180910390f35b3480156101e057600080fd5b506101e96102a8565b60405180826000191660001916815260200191505060405180910390f35b34801561021357600080fd5b50610232600480360381019080803590602001909291905050506102b2565b005b600080602a60005401600154915091509091565b6000600260009054906101000a900460ff16905090565b806001816000191690555050565b600080600054600154915091509091565b80600260006101000a81548160ff02191690831515021790555050565b6000602a82019050919050565b6000600154905090565b80600081905550505600a165627a7a72305820011e5b9e0027011168cadc65c33ba8af814dfcfbf4a1b9683f48fa17bcb352500029 \ No newline at end of file diff --git a/test/examples/contracts/Complex.sol b/test/examples/contracts/Complex.sol index 8ccafca..7288354 100644 --- a/test/examples/contracts/Complex.sol +++ b/test/examples/contracts/Complex.sol @@ -45,4 +45,7 @@ contract Complex { function setBarFoo(bool _barFoo) public { barFoo = _barFoo; } + + function() public payable { } + } \ No newline at end of file