Merge pull request #931 from konstantinzolotarev/ganache_fixes

Fixes for ganache integration
pull/939/head
Luke Imhoff 6 years ago committed by GitHub
commit 32100c2132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex
  2. 32
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transaction.ex
  3. 20
      apps/explorer/config/dev/ganache.exs
  4. 20
      apps/indexer/config/dev/ganache.exs

@ -372,8 +372,9 @@ defmodule EthereumJSONRPC do
# We can only depend on implementations supporting 64-bit integers: # We can only depend on implementations supporting 64-bit integers:
# * Parity only supports u64 (https://github.com/paritytech/jsonrpc-core/blob/f2c61edb817e344d92ab3baf872fa77d1602430a/src/id.rs#L13) # * Parity only supports u64 (https://github.com/paritytech/jsonrpc-core/blob/f2c61edb817e344d92ab3baf872fa77d1602430a/src/id.rs#L13)
# * Ganache only supports u32 (https://github.com/trufflesuite/ganache-core/issues/190)
def unique_request_id do def unique_request_id do
<<unique_request_id::big-integer-size(8)-unit(8)>> = :crypto.strong_rand_bytes(8) <<unique_request_id::big-integer-size(4)-unit(8)>> = :crypto.strong_rand_bytes(4)
unique_request_id unique_request_id
end end

@ -137,6 +137,38 @@ defmodule EthereumJSONRPC.Transaction do
} }
end end
# Ganache bug. it return `to: "0x0"` except of `to: null`
def elixir_to_params(
%{
"to" => "0x0"
} = transaction
) do
%{transaction | "to" => nil}
|> elixir_to_params()
end
# Ganache bug. It don't send `r,s,v` transaction fields.
# Fix is in sources but not released yet
def elixir_to_params(
%{
"blockHash" => _,
"blockNumber" => _,
"from" => _,
"gas" => _,
"gasPrice" => _,
"hash" => _,
"input" => _,
"nonce" => _,
"to" => _,
"transactionIndex" => _,
"value" => _
} = transaction
) do
transaction
|> Map.merge(%{"r" => 0, "s" => 0, "v" => 0})
|> elixir_to_params()
end
@doc """ @doc """
Extracts `t:EthereumJSONRPC.hash/0` from transaction `params` Extracts `t:EthereumJSONRPC.hash/0` from transaction `params`

@ -0,0 +1,20 @@
use Mix.Config
config :explorer,
json_rpc_named_arguments: [
transport: EthereumJSONRPC.HTTP,
transport_options: [
http: EthereumJSONRPC.HTTP.HTTPoison,
url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "http://localhost:7545",
http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]]
],
variant: EthereumJSONRPC.Geth
],
subscribe_named_arguments: [
transport: EthereumJSONRPC.WebSocket,
transport_options: [
web_socket: EthereumJSONRPC.WebSocket.WebSocketClient,
url: System.get_env("ETHEREUM_JSONRPC_WEB_SOCKET_URL") || "ws://localhost:7545"
],
variant: EthereumJSONRPC.Geth
]

@ -0,0 +1,20 @@
use Mix.Config
config :indexer,
block_interval: 5_000,
json_rpc_named_arguments: [
transport: EthereumJSONRPC.HTTP,
transport_options: [
http: EthereumJSONRPC.HTTP.HTTPoison,
url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "http://localhost:7545",
http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]]
],
variant: EthereumJSONRPC.Geth
],
subscribe_named_arguments: [
transport: EthereumJSONRPC.WebSocket,
transport_options: [
web_socket: EthereumJSONRPC.WebSocket.WebSocketClient,
url: System.get_env("ETHEREUM_JSONRPC_WEB_SOCKET_URL") || "ws://localhost:7545"
]
]
Loading…
Cancel
Save