Arnaud 36dd1086ab
Update for Nim 2.0.x (#9)
* Update for Nim 2.0.x

* Update to Nim 2.0.14

* use version range for deps, bump nimcrypto

* remove 1.6 from ci test

* Update the lock file again

* fromBytes -> fromBytesBE

---------

Co-authored-by: Eric <5089238+emizzle@users.noreply.github.com>
2025-02-13 15:24:34 +11:00

30 lines
679 B
Nim

import std/random
import std/sequtils
import pkg/stint
import pkg/contractabi/address
randomize()
proc example*(_: type bool): bool =
rand(0'u8..1'u8) == 1
proc example*[T: SomeInteger](_: type T): T =
rand(T)
proc example*[I: static int, T](_: type array[I, T]): array[I, T] =
for i in 0..<I:
result[i] = T.example
proc example*[T](_: type seq[T], len = 0..5): seq[T] =
let chosenlen = rand(len)
newSeqWith(chosenlen, T.example)
proc example*(T: type StUint): T =
T.fromBytesBE(array[sizeof(T), byte].example)
proc example*(T: type StInt): T =
cast[T](StUint[T.bits].example)
proc example*(T: type Address): T =
Address.init(array[20, byte].example)