View Source Signet.Typed.Domain (Signet v0.1.7)

Link to this section Summary

Functions

Deserializes a domain from JSON or JavaScript encoding to a struct.

Serializes a domain, such that it can be JSON-encoded or passed to JavaScript.

Serializes a domain's keys to be JSON-compatible. This is so that it can be used as a value for hashStruct, per the EIP-712 spec to build a domain specifier.

Link to this section Types

@type t() :: %Signet.Typed.Domain{
  chain_id: number(),
  name: String.t(),
  verifying_contract: <<_::160>>,
  version: String.t()
}

Link to this section Functions

Deserializes a domain from JSON or JavaScript encoding to a struct.

examples

Examples

iex> %{
...>   "name" => "Ether Mail",
...>   "version" => "1",
...>   "chainId" => 1,
...>   "verifyingContract" => "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
...> }
...> |> Signet.Typed.Domain.deserialize()
%Signet.Typed.Domain{
  name: "Ether Mail",
  version: "1",
  chain_id: 1,
  verifying_contract: <<204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204>>
}

Serializes a domain, such that it can be JSON-encoded or passed to JavaScript.

examples

Examples

iex> %Signet.Typed.Domain{
...>   name: "Ether Mail",
...>   version: "1",
...>   chain_id: 1,
...>   verifying_contract: <<204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204>>
...> }
...> |> Signet.Typed.Domain.serialize()
%{
  "name" => "Ether Mail",
  "version" => "1",
  "chainId" => 1,
  "verifyingContract" => "0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
}

Serializes a domain's keys to be JSON-compatible. This is so that it can be used as a value for hashStruct, per the EIP-712 spec to build a domain specifier.

examples

Examples

iex> %Signet.Typed.Domain{
...>   name: "Ether Mail",
...>   version: "1",
...>   chain_id: 1,
...>   verifying_contract: <<204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204>>
...> }
...> |> Signet.Typed.Domain.serialize_keys()
%{
  "name" => "Ether Mail",
  "version" => "1",
  "chainId" => 1,
  "verifyingContract" => <<204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204>>
}