mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-07 08:03:14 +00:00
25 lines
522 B
Nim
25 lines
522 B
Nim
import std/math
|
|
import pkg/questionable
|
|
import pkg/stint
|
|
import pkg/stew/byteutils
|
|
|
|
include questionable/errorban
|
|
|
|
export stint
|
|
export questionable
|
|
|
|
type
|
|
UInt48* = range[0'u64..2'u64^48-1]
|
|
EthAddress* = distinct array[20, byte]
|
|
|
|
proc toArray*(address: EthAddress): array[20, byte] =
|
|
array[20, byte](address)
|
|
|
|
proc fromHex*(_: type EthAddress, hex: string): ?EthAddress =
|
|
try:
|
|
EthAddress(array[20, byte].fromHex(hex)).some
|
|
except ValueError:
|
|
EthAddress.none
|
|
|
|
proc `==`*(a, b: EthAddress): bool {.borrow.}
|