defmodule Explorer.Log do @moduledoc "Captures a Web3 log entry generated by a transaction" use Ecto.Schema import Ecto.Changeset alias Explorer.Address alias Explorer.Log alias Explorer.TransactionReceipt @timestamps_opts [type: Timex.Ecto.DateTime, autogenerate: {Timex.Ecto.DateTime, :autogenerate, []}] @required_attrs ~w(index data removed)a schema "logs" do belongs_to :transaction_receipt, TransactionReceipt belongs_to :address, Address has_one :transaction, through: [:transaction_receipt, :transaction] field :index, :integer field :data, :string field :removed, :boolean field :first_topic, :string field :second_topic, :string field :third_topic, :string timestamps() end def changeset(%Log{} = log, attrs \\ %{}) do log |> cast(attrs, @required_attrs) |> validate_required(@required_attrs) end end