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

get rid of dynamic code generation #10

Merged
merged 16 commits into from
Oct 15, 2017
26 changes: 26 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
jobs:
build:
working_directory: ~/ethereumex
docker:
- image: elixir:latest
- image: parity/parity:v1.7.2
command: [
parity, --chain=kovan
--jsonrpc-apis net,parity,parity_accounts,eth,web3
--unlock 0x71cf0b576a95c347078ec2339303d13024a26910
--password ~/ethereumex/.circleci/password.txt
--warp
--pruning=archive
]
steps:
- checkout
- restore_cache:
key: _build
- run: mix local.hex --force
- run: mix deps.get
- run: mix test --include eth --include batch
- run: mix dialyzer
- save_cache:
key: _build
paths:
- _build
1 change: 1 addition & 0 deletions .circleci/password.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rock
14 changes: 14 additions & 0 deletions .credo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
%{
configs: [
%{
name: "default",
files: %{
included: ["lib/", "src/", "web/", "apps/"],
excluded: []
},
checks: [
{Credo.Check.Refactor.LongQuoteBlocks, false}
]
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ethereumex [![Build Status](https://semaphoreci.com/api/v1/ayrat555/ethereumex/branches/master/badge.svg)](https://semaphoreci.com/ayrat555/ethereumex)
# Ethereumex [![CircleCI](https://circleci.com/gh/exthereum/ethereumex.svg?style=svg)](https://circleci.com/gh/exthereum/ethereumex)

Elixir JSON-RPC client for the Ethereum blockchain

Expand Down
22 changes: 0 additions & 22 deletions fixture/vcr_cassettes/http_client_custom_request.json

This file was deleted.

22 changes: 0 additions & 22 deletions fixture/vcr_cassettes/http_client_failed_request.json

This file was deleted.

22 changes: 0 additions & 22 deletions fixture/vcr_cassettes/http_client_net_version_request.json

This file was deleted.

22 changes: 0 additions & 22 deletions fixture/vcr_cassettes/http_client_request.json

This file was deleted.

22 changes: 0 additions & 22 deletions fixture/vcr_cassettes/http_client_request_with_map_params.json

This file was deleted.

74 changes: 74 additions & 0 deletions lib/ethereumex/client/behaviour.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
defmodule Ethereumex.Client.Behaviour do
@type error :: {:error, map() | binary() | atom()}

# API methods

@callback web3_client_version(keyword()) :: {:ok, binary()} | error
@callback web3_sha3(binary(), keyword()) :: {:ok, binary()} | error
@callback net_version(keyword()) :: {:ok, binary()} | error
@callback net_peer_count(keyword()) :: {:ok, binary()} | error
@callback net_listening(keyword()) :: {:ok, boolean()} | error
@callback eth_protocol_version(keyword()) :: {:ok, binary()} | error
@callback eth_syncing(keyword()) :: {:ok, map() | true} | error
@callback eth_coinbase(keyword()) :: {:ok, binary()} | error
@callback eth_mining(keyword()) :: {:ok, boolean()} | error
@callback eth_hashrate(keyword()) :: {:ok, binary()} | error
@callback eth_gas_price(keyword()) :: {:ok, binary()} | error
@callback eth_accounts(keyword()) :: {:ok, [binary()]} | error
@callback eth_block_number(keyword()) :: {:ok, binary} | error
@callback eth_get_balance(binary(), binary(), keyword()) :: {:ok, binary()} | error
@callback eth_get_storage_at(binary(), binary(), binary(), keyword()) :: {:ok, binary()} | error
@callback eth_get_transaction_count(binary(), binary(), keyword()) :: {:ok, binary()} | error
@callback eth_get_block_transaction_count_by_hash(binary(), keyword()) :: {:ok, binary()} | error
@callback eth_get_block_transaction_count_by_number(binary(), keyword()) :: {:ok, binary()} | error
@callback eth_get_uncle_count_by_block_hash(binary(), keyword()) :: {:ok, binary()} | error
@callback eth_get_uncle_count_by_block_number(binary(), keyword()) :: {:ok, binary()} | error
@callback eth_get_code(binary(), binary(), keyword()) :: {:ok, binary()} | error
@callback eth_sign(binary(), binary(), keyword()) :: {:ok, binary()} | error
@callback eth_send_transaction(map(), keyword()) :: {:ok, binary()} | error
@callback eth_send_raw_transaction(binary(), keyword()) :: {:ok, binary()} | error
@callback eth_call(map, binary(), keyword()) :: {:ok, binary()} | error
@callback eth_estimate_gas(map(), binary(), keyword()) :: {:ok, binary()} | error
@callback eth_get_block_by_hash(binary(), binary(), keyword()) :: {:ok, map()} | error
@callback eth_get_block_by_number(binary(), binary(), keyword()) :: {:ok, map()} | error
@callback eth_get_transaction_by_hash(binary(), keyword()) :: {:ok, map()} | error
@callback eth_get_transaction_by_block_hash_and_index(binary(), binary(), keyword()) :: {:ok, map()} | error
@callback eth_get_transaction_by_block_number_and_index(binary(), binary(), keyword()) :: {:ok, binary()} | error
@callback eth_get_transaction_receipt(binary(), keyword()) :: {:ok, map()} | error
@callback eth_get_uncle_by_block_hash_and_index(binary(), binary(), keyword()) :: {:ok, map()} | error
@callback eth_get_uncle_by_block_number_and_index(binary(), binary(), keyword()) :: {:ok, map()} | error
@callback eth_get_compilers(keyword()) :: {:ok, [binary()]} | error
@callback eth_compile_lll(binary(), keyword()) :: {:ok, binary()} | error
@callback eth_compile_solidity(binary(), keyword()) :: {:ok, binary()} | error
@callback eth_compile_serpent(binary(), keyword()) :: {:ok, binary()} | error
@callback eth_new_filter(map(), keyword()) :: {:ok, binary()} | error
@callback eth_new_block_filter(keyword()) :: {:ok, binary()} | error
@callback eth_new_pending_transaction_filter(keyword()) :: {:ok, binary()} | error
@callback eth_uninstall_filter(binary(), keyword()) :: {:ok, boolean()} | error
@callback eth_get_filter_changes(binary(), keyword()) :: {:ok, [binary()] | [map()]} | error
@callback eth_get_filter_logs(binary(), keyword()) :: {:ok, [binary()] | [map()]} | error
@callback eth_get_logs(map(), keyword()) :: {:ok, [binary()] | [map()]} | error
@callback eth_get_work(keyword()) :: {:ok, [binary()]} | error
@callback eth_submit_work(binary(), binary(), binary(), keyword()) :: {:ok, boolean()} | error
@callback eth_submit_hashrate(binary(), binary(), keyword()) :: {:ok, boolean()} | error
@callback db_put_string(binary(), binary(), binary(), keyword()) :: {:ok, boolean()} | error
@callback db_get_string(binary(), binary(), keyword()) :: {:ok, binary()} | error
@callback db_put_hex(binary(), binary(), binary(), keyword()) :: {:ok, boolean()} | error
@callback db_get_hex(binary(), binary(), keyword()) :: {:ok, binary()} | error
@callback shh_post(map(), keyword()) :: {:ok, boolean()} | error
@callback shh_version(keyword()) :: {:ok, binary()} | error
@callback shh_new_identity(keyword()) :: {:ok, binary()} | error
@callback shh_has_identity(binary(), keyword()) :: {:ok, boolean} | error
@callback shh_new_group(keyword()) :: {:ok, binary()} | error
@callback shh_add_to_group(binary(), keyword()) :: {:ok, boolean()} | error
@callback shh_new_filter(map(), keyword()) :: {:ok, binary()} | error
@callback shh_uninstall_filter(binary(), keyword()) :: {:ok, binary()} | error
@callback shh_get_filter_changes(binary(), keyword()) :: {:ok, [map()]} | error
@callback shh_get_messages(binary(), keyword()) :: {:ok, [map()]} | error

# actual request methods

@callback request(binary(), list(binary()), keyword()) :: {:ok, any() | [any()]} | error
@callback single_request(map()) :: {:ok, any() | [any()]} | error
@callback batch_request([{atom(), list(binary())}]) :: {:ok, [any()]} | error
end
Loading