Skip to content

Commit

Permalink
remove unused skip0xPrefix
Browse files Browse the repository at this point in the history
`skip0xPrefix` is no longer used since #108 where its usage was replaced
with `stew/byteutils`' hexToSeqByte`.
  • Loading branch information
etan-status committed Jan 6, 2024
1 parent be1bb30 commit 6413dd7
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions web3/primitives.nim
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,6 @@ template toHex*(x: Address): string =
template fromHex*(T: type Address, hexStr: string): T =
T fromHex(distinctBase(T), hexStr)

template skip0xPrefix(hexStr: string): int =
## Returns the index of the first meaningful char in `hexStr` by skipping
## "0x" prefix
if hexStr.len > 1 and hexStr[0] == '0' and hexStr[1] in {'x', 'X'}: 2
else: 0

func strip0xPrefix*(s: string): string =
let prefixLen = skip0xPrefix(s)
if prefixLen != 0:
s[prefixLen .. ^1]
else:
s

func fromHex*[minLen, maxLen](T: type DynamicBytes[minLen, maxLen], hexStr: string): T {.raises: [ValueError].} =
let prefixLen = skip0xPrefix(hexStr)
let hexDataLen = hexStr.len - prefixLen
Expand Down

0 comments on commit 6413dd7

Please sign in to comment.