Skip to content

Commit

Permalink
Updated eth_chainId to remove 0 padding from hex.
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicletz committed Oct 15, 2020
1 parent 2e8ee08 commit 5d4ac2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/network/rpc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ defmodule Network.Rpc do
result(Diode.syncing?())

"eth_chainId" ->
result(Diode.chain_id())
id =
Diode.chain_id()
|> :binary.encode_unsigned()
|> Base.encode16(case: :lower)
|> String.trim_leading("0")

result("0x" <> id)

"eth_getTransactionByHash" ->
[txh] = params
Expand Down
5 changes: 5 additions & 0 deletions test/curl_rpc.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Licensed under the Diode License, Version 1.0
if [[ $1 == "" ]]; then
echo "Need host parameter"
echo "You can try localhost:8545"
exit
fi

Expand All @@ -12,6 +13,10 @@ host=$1
# Just some rpc examples using curl
# curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":["0x16"],"id":73}' $host

echo "Chain ID:"
curl -k -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","id":73}' $host
echo ""

# Counts the number of fleet contracts
echo "Total Fleets:"
curl -k -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"dio_codeCount","params":["0x7e9d94e966d33cff302ef86e2337df8eaf9a6388d45e4744321240599d428343"],"id":73}' $host
Expand Down

0 comments on commit 5d4ac2c

Please sign in to comment.