From 3e99be297f5c4a0c45d5dcc296a849d9898c05c3 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 2 Oct 2024 09:17:00 +0200 Subject: [PATCH] readd toArray that went mssing (#163) --- web3/primitives.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web3/primitives.nim b/web3/primitives.nim index 51d58e4..06a98be 100644 --- a/web3/primitives.nim +++ b/web3/primitives.nim @@ -40,7 +40,6 @@ type # Quantity is use in lieu of an ordinary `uint64` to avoid the default # format that comes with json_serialization - Blob* = FixedBytes[fieldElementsPerBlob * 32] template `==`*[minLen, maxLen](a, b: DynamicBytes[minLen, maxLen]): bool = @@ -80,6 +79,9 @@ func fromHex*[minLen, maxLen](T: type DynamicBytes[minLen, maxLen], hexStr: stri T hexToSeqByte(hexStr) +func toArray*[N](data: DynamicBytes[N, N]): array[N, byte] = + copyMem(addr result[0], unsafeAddr distinctBase(data)[0], N) + template data*(v: DynamicBytes): seq[byte] = distinctBase v