mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-03 22:23:10 +00:00
Print EthAddress as hex, add zero address
This commit is contained in:
parent
405ba8efd4
commit
11a2329bf2
@ -5,9 +5,15 @@ export questionable
|
||||
|
||||
type EthAddress* = distinct array[20, byte]
|
||||
|
||||
proc zero*(_: type EthAddress): EthAddress =
|
||||
EthAddress.default
|
||||
|
||||
proc toArray*(address: EthAddress): array[20, byte] =
|
||||
array[20, byte](address)
|
||||
|
||||
proc `$`*(a: EthAddress): string =
|
||||
a.toArray().toHex()
|
||||
|
||||
proc parse*(_: type EthAddress, hex: string): ?EthAddress =
|
||||
EthAddress(array[20, byte].fromHex(hex)).catch.toOption
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user