Siwa.Ethereum (siwa v0.1.1)

Copy Markdown

Ethereum helpers used by SIWA flows.

Summary

Types

address()

@type address() :: String.t()

error()

@type error() ::
  :invalid_address
  | :invalid_ens_name
  | :invalid_payload
  | :invalid_token_id
  | :token_id_too_large
  | :rpc_url_required
  | :rpc_request_failed
  | :rpc_request_timed_out
  | :invalid_rpc_response
  | :invalid_owner
  | {:rpc_error, String.t()}

hex_data()

@type hex_data() :: String.t()

Functions

decode_owner_of_result(arg1)

@spec decode_owner_of_result(term()) :: {:ok, address()} | {:error, :invalid_owner}

json_rpc(url, method, params, opts \\ [])

@spec json_rpc(binary(), binary(), list(), keyword()) ::
  {:ok, term()} | {:error, error()}

keccak_hex(payload)

@spec keccak_hex(binary()) :: {:ok, hex_data()} | {:error, :invalid_payload}

namehash(name)

@spec namehash(binary()) :: {:ok, hex_data()} | {:error, :invalid_ens_name}

normalize_address(value)

@spec normalize_address(term()) :: {:ok, address()} | {:error, :invalid_address}

normalize_token_id(value)

@spec normalize_token_id(term()) :: {:ok, String.t()} | {:error, :invalid_token_id}

owner_of(registry_address, token_id, rpc_url, opts \\ [])

@spec owner_of(binary(), binary(), binary(), keyword()) ::
  {:ok, address()} | {:error, error()}

owner_of_call_data(token_id)

@spec owner_of_call_data(binary()) ::
  {:ok, hex_data()} | {:error, :invalid_token_id | :token_id_too_large}

valid_address?(value)

@spec valid_address?(term()) :: boolean()

valid_tx_hash?(value)

@spec valid_tx_hash?(term()) :: boolean()