View Source Signet.Trace.Action (Signet v1.3.8)

Summary

Functions

Deserializes a trace sub-action into a struct.

Serializes a struct into a json map.

Types

@type t() :: %Signet.Trace.Action{
  balance: integer() | nil,
  call_type: String.t() | nil,
  from: <<_::160>>,
  gas: integer(),
  init: binary() | nil,
  input: binary(),
  refund_address: binary() | nil,
  to: <<_::160>> | nil,
  value: integer()
}

Functions

@spec deserialize(map()) :: t() | no_return()

Deserializes a trace sub-action into a struct.

Examples

iex> use Signet.Hex
iex> %{
...>   "callType" => "call",
...>   "from" => "0x83806d539d4ea1c140489a06660319c9a303f874",
...>   "gas" => "0x1a1f8",
...>   "input" => "0x",
...>   "to" => "0x1c39ba39e4735cb65978d4db400ddd70a72dc750",
...>   "value" => "0x7a16c911b4d00000"
...> }
...> |> Signet.Trace.Action.deserialize()
%Signet.Trace.Action{
  call_type: "call",
  from: ~h[0x83806d539d4ea1c140489a06660319c9a303f874],
  gas: 0x01a1f8,
  input: <<>>,
  to: ~h[0x1c39ba39e4735cb65978d4db400ddd70a72dc750],
  value: 0x7a16c911b4d00000,
}

iex> use Signet.Hex
iex> %{
...>   "callType" => "call",
...>   "from" => "0x0000000000000000000000000000000000000000",
...>   "gas" => "0x1dcd0f58",
...>   "input" =>
...>     "0xd1692f56000000000000000000000000142da9114e5a98e015aa95afca0585e84832a612000000000000000000000000142da9114e5a98e015aa95afca0585e84832a6120000000000000000000000000000000000000000000000000000000000000000",
...>   "to" => "0x13172ee393713fba9925a9a752341ebd31e8d9a7",
...>   "value" => "0x0"
...> }
...> |> Signet.Trace.Action.deserialize()
%Signet.Trace.Action{
  call_type: "call",
  from: ~h[0x0000000000000000000000000000000000000000],
  gas: 0x1dcd0f58,
  input: ~h[0xd1692f56000000000000000000000000142da9114e5a98e015aa95afca0585e84832a612000000000000000000000000142da9114e5a98e015aa95afca0585e84832a6120000000000000000000000000000000000000000000000000000000000000000],
  to: ~h[0x13172ee393713fba9925a9a752341ebd31e8d9a7],
  value: 0x0,
}

iex> use Signet.Hex
iex> %{
...>   "address" => "0x1a6b1b60d09944d56d39ef53a6b81097615f5ee4",
...>   "balance" => "0x0",
...>   "refundAddress" => "0x0000000000b3f879cb30fe243b4dfee438691c04"
...> }
...> |> Signet.Trace.Action.deserialize()
%Signet.Trace.Action{
  refund_address: ~h[0x0000000000b3f879cb30fe243b4dfee438691c04],
  balance: 0x0,
}
@spec serialize(t()) :: map()

Serializes a struct into a json map.

Examples

iex> use Signet.Hex
iex> %Signet.Trace.Action{
...>   call_type: "call",
...>   from: ~h[0x83806d539d4ea1c140489a06660319c9a303f874],
...>   gas: 0x01a1f8,
...>   input: <<>>,
...>   to: ~h[0x1c39ba39e4735cb65978d4db400ddd70a72dc750],
...>   value: 0x7a16c911b4d00000,
...> }
...> |> Signet.Trace.Action.serialize()
%{
  from: "0x83806d539D4Ea1c140489A06660319C9A303f874",
  gas: "0x1A1F8",
  input: "0x",
  to: "0x1C39BA39e4735CB65978d4Db400dDD70a72DC750",
  value: "0x7A16C911B4D00000",
  callType: "call",
  init: nil
}