diff --git a/lib/tt_eth/local_wallet.ex b/lib/tt_eth/local_wallet.ex index b16c4cf..a869159 100644 --- a/lib/tt_eth/local_wallet.ex +++ b/lib/tt_eth/local_wallet.ex @@ -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!(), diff --git a/lib/tt_eth/wallet.ex b/lib/tt_eth/wallet.ex index 3c63ec9..b23b08c 100644 --- a/lib/tt_eth/wallet.ex +++ b/lib/tt_eth/wallet.ex @@ -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, @@ -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) @@ -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) diff --git a/test/tt_eth/wallet_test.exs b/test/tt_eth/wallet_test.exs index de83b0a..f56b324 100644 --- a/test/tt_eth/wallet_test.exs +++ b/test/tt_eth/wallet_test.exs @@ -55,7 +55,6 @@ defmodule TTEth.WalletTest do wallet |> assert_match(%Wallet{ - adapter: LocalWallet, address: ^address, public_key: ^public_key, human_address: ^human_address,