2021-03-09 09:37:27 +01:00
|
|
|
import pkg/questionable
|
2021-02-25 09:11:46 +01:00
|
|
|
import pkg/stew/byteutils
|
2021-02-22 15:32:48 +01:00
|
|
|
|
2021-03-09 09:37:27 +01:00
|
|
|
export questionable
|
2021-02-22 15:32:48 +01:00
|
|
|
|
2021-03-09 11:07:35 +01:00
|
|
|
type EthAddress* = distinct array[20, byte]
|
2021-02-23 10:23:42 +01:00
|
|
|
|
|
|
|
|
proc toArray*(address: EthAddress): array[20, byte] =
|
|
|
|
|
array[20, byte](address)
|
|
|
|
|
|
2021-03-09 14:05:32 +01:00
|
|
|
proc parse*(_: type EthAddress, hex: string): ?EthAddress =
|
2021-03-09 11:07:35 +01:00
|
|
|
EthAddress(array[20, byte].fromHex(hex)).catch.toOption
|
2021-02-25 09:11:46 +01:00
|
|
|
|
2021-02-23 10:23:42 +01:00
|
|
|
proc `==`*(a, b: EthAddress): bool {.borrow.}
|