View Source Signet.Typed.Domain (Signet v1.3.8)
Summary
Functions
Deserializes a domain from JSON or JavaScript encoding to a struct.
Builds the EIP-712 domain type based on a given domain.
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.
Types
Functions
Deserializes a domain from JSON or JavaScript encoding to a struct.
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: ~h[CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC]
}
iex> %{
...> "name" => "Ether Mail",
...> "version" => "1"
...> }
...> |> Signet.Typed.Domain.deserialize()
%Signet.Typed.Domain{
name: "Ether Mail",
version: "1"
}
Builds the EIP-712 domain type based on a given domain.
Examples
iex> %Signet.Typed.Domain{
...> name: "Ether Mail",
...> version: "1",
...> chain_id: 1,
...> verifying_contract: ~h[CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC]
...> }
...> |> Signet.Typed.Domain.domain_type()
%{"EIP712Domain" => %Signet.Typed.Type{fields: [{"name", :string}, {"version", :string}, {"chainId", {:uint, 256}}, {"verifyingContract", :address}]}}
iex> %Signet.Typed.Domain{
...> name: "Ether Mail",
...> version: "1",
...> }
...> |> Signet.Typed.Domain.domain_type()
%{"EIP712Domain" => %Signet.Typed.Type{fields: [{"name", :string}, {"version", :string}]}}
Serializes a domain, such that it can be JSON-encoded or passed to JavaScript.
Examples
iex> %Signet.Typed.Domain{
...> name: "Ether Mail",
...> version: "1",
...> chain_id: 1,
...> verifying_contract: ~h[CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC]
...> }
...> |> Signet.Typed.Domain.serialize()
%{
"name" => "Ether Mail",
"version" => "1",
"chainId" => 1,
"verifyingContract" => "0xcccccccccccccccccccccccccccccccccccccccc",
}
iex> %Signet.Typed.Domain{
...> name: "Ether Mail",
...> version: "1"
...> }
...> |> Signet.Typed.Domain.serialize()
%{
"name" => "Ether Mail",
"version" => "1"
}
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
iex> use Signet.Hex
iex> %Signet.Typed.Domain{
...> name: "Ether Mail",
...> version: "1",
...> chain_id: 1,
...> verifying_contract: ~h[CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC]
...> }
...> |> Signet.Typed.Domain.serialize_keys()
%{
"name" => "Ether Mail",
"version" => "1",
"chainId" => 1,
"verifyingContract" => ~h[CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC]
}
iex> use Signet.Hex
iex> %Signet.Typed.Domain{
...> name: "Ether Mail",
...> version: "1",
...> }
...> |> Signet.Typed.Domain.serialize_keys()
%{
"name" => "Ether Mail",
"version" => "1"
}