|
|
|
@ -23,9 +23,9 @@ defmodule ExW3 do |
|
|
|
|
Enum.join(["0x", bytes |> Base.encode16(case: :lower)], "") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@spec to_checksum_address(binary()) :: binary() |
|
|
|
|
@doc "returns a checksummed address" |
|
|
|
|
def to_checksum_address(address) do |
|
|
|
|
@spec to_checksum_address(binary()) :: binary() |
|
|
|
|
@doc "returns a checksummed address" |
|
|
|
|
def to_checksum_address(address) do |
|
|
|
|
address = String.replace(address, ~r/^0x/, "") |
|
|
|
|
|
|
|
|
|
{:ok, hash} = Ethereumex.HttpClient.web3_sha3(String.downcase(address)) |
|
|
|
@ -45,8 +45,8 @@ defmodule ExW3 do |
|
|
|
|
"0x" <> List.to_string(list_arr) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@doc "checks if the address is a valid checksummed address" |
|
|
|
|
@spec is_valid_checksum_address(binary()) :: boolean() |
|
|
|
|
@doc "checks if the address is a valid checksummed address" |
|
|
|
|
@spec is_valid_checksum_address(binary()) :: boolean() |
|
|
|
|
def is_valid_checksum_address(address) do |
|
|
|
|
to_checksum_address(address) == address |
|
|
|
|
end |
|
|
|
|