fix transaction input

pull/2341/head
Ayrat Badykov 5 years ago
parent 09e69efb0c
commit 10d5b69d8e
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 19
      apps/explorer/lib/explorer/chain/data.ex
  2. 14
      apps/explorer/test/explorer/chain/transaction_test.exs

@ -7,6 +7,7 @@ defmodule Explorer.Chain.Data do
"""
alias Explorer.Chain.Data
alias Poison.Encoder.BitString
@behaviour Ecto.Type
@ -380,4 +381,22 @@ defmodule Explorer.Chain.Data do
@for.to_string(data)
end
end
defimpl Poison.Encoder do
def encode(data, options) do
data
|> to_string()
|> BitString.encode(options)
end
end
defimpl Jason.Encoder do
alias Jason.Encode
def encode(data, opts) do
data
|> to_string()
|> Encode.string(opts)
end
end
end

@ -286,4 +286,18 @@ defmodule Explorer.Chain.TransactionTest do
assert Transaction.decoded_input_data(transaction) == {:ok, "60fe47b1", "set(uint256 x)", [{"x", "uint256", 10}]}
end
end
describe "Poison.encode!/1" do
test "encodes transaction input" do
assert %{
insert(:transaction)
| input: %Explorer.Chain.Data{
bytes:
<<169, 5, 156, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 193, 108, 45, 196, 42, 228, 149, 239, 119,
191, 128, 248>>
}
}
|> Poison.encode!()
end
end
end

Loading…
Cancel
Save