Skip to content

Commit

Permalink
Drops unused adapter key from Wallet.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesduncombe committed Feb 1, 2024
1 parent a386345 commit 2f19f85
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/tt_eth/local_wallet.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ defmodule TTEth.LocalWallet do
address = pub |> Address.from_public_key!()

[
adapter: @for,
address: address,
public_key: pub,
human_address: address |> Address.to_human!(),
Expand Down
21 changes: 17 additions & 4 deletions lib/tt_eth/wallet.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ defmodule TTEth.Wallet do
"""
alias TTEth.Protocols.Wallet, as: WalletProtocol
alias TTEth.Type.Signature, as: EthSignature
alias TTEth.Type.Address, as: EthAddress
alias TTEth.Type.PublicKey, as: EthPublicKey

@type t :: %__MODULE__{}
@typedoc """
Represents a Wallet.
The underlying adapter lives under `_adapter`.
"""
@type t :: %__MODULE__{
address: EthAddress.t(),
public_key: EthPublicKey.t(),
human_address: String.t(),
human_public_key: String.t(),
_adapter: struct()
}

@enforce_keys [:address, :public_key, :human_address, :human_public_key, :_adapter]
defstruct [
:adapter,
:address,
:public_key,
:human_address,
Expand Down Expand Up @@ -63,7 +76,7 @@ defmodule TTEth.Wallet do
|> WalletProtocol.sign(hash_digest)

@doc """
The same as `sign/2` but raises if the signing process is not successful.
Same as `sign/2` but raises if the signing process is not successful.
"""
def sign!(%__MODULE__{} = wallet, "" <> hash_digest) do
{:ok, ret} = wallet |> sign(hash_digest)
Expand All @@ -84,7 +97,7 @@ defmodule TTEth.Wallet do
|> sign(plaintext |> EthSignature.digest())

@doc """
The same as `personal_sign/2` but raises if the signing process is not successful.
Same as `personal_sign/2` but raises if the signing process is not successful.
"""
def personal_sign!(%__MODULE__{} = wallet, "" <> plaintext) do
{:ok, comps} = wallet |> personal_sign(plaintext)
Expand Down
1 change: 0 additions & 1 deletion test/tt_eth/wallet_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ defmodule TTEth.WalletTest do

wallet
|> assert_match(%Wallet{
adapter: LocalWallet,
address: ^address,
public_key: ^public_key,
human_address: ^human_address,
Expand Down

0 comments on commit 2f19f85

Please sign in to comment.